标题翻译
java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar error using Selenium through Maven in Spring Boot
问题
这是您要翻译的内容:
我在尝试配置Selenium WebDriver以测试我的Spring Boot应用程序时遇到了各种问题。每次我将Selenium依赖项放入我的pom.xml中,似乎都会损坏我的m2仓库,或者至少我是这么认为的。
以下是依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
以下是错误信息:
Exception in thread "main" java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:132)
at org.springframework.boot.devtools.restart.ChangeableUrls.fromClassLoader(ChangeableUrls.java:98)
at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:92)
...
我尝试过多次清理我的m2仓库,并添加不同版本的依赖项,但似乎没有解决问题。我还尝试过使用clean install
命令,但如果我加入了Selenium依赖项,它会显示构建错误。
英文翻译
I have been running in to various issues while trying to configure selenium webdriver to test my spring boot application. Every time I put the selenium dependency in to my pom.xml it seems to corrupt my m2 repository, or that is what I think.
This is the dependency:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
This is the error message:
Exception in thread "main" java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:132)
at org.springframework.boot.devtools.restart.ChangeableUrls.fromClassLoader(ChangeableUrls.java:98)
at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:92)
at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)
at org.springframework.boot.devtools.restart.Restarter.<init>(Restarter.java:142)
at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:556)
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:76)
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:50)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at pe.backend.BackendApplication.main(BackendApplication.java:10)
I have tried cleaning my m2 repository various times and adding different versions of the dependency, but It doesn’t seem to solve it. I have also tried using clean install, but it shows a build error if I have put the selenium dependency.
答案1
得分: 0
这个错误信息...
在主线程中出现异常:“main” java.lang.IllegalStateException: 无法从jar文件的清单中读取Class-Path属性:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
...暗示着你的Maven缓存中有一个JAR文件损坏了。
在你的情况下,似乎是以下文件损坏了:
file:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
解决方案
你需要从你的Maven缓存中移除这个特定的JAR文件,然后重新构建你的应用程序。
尽管你已经尝试过多次通过"clean install"清理m2
仓库,但错误仍然存在,你可能需要彻底删除这个特定的_jar_文件,然后重新构建你的应用程序。
结尾
你可以在以下讨论中找到相关的讨论:
英文翻译
This error message...
Exception in thread "main" java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
...implies that one of the jars in your maven cache corrupted.
In your case, it seems the the following file got corrupted:
file:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
Solution
You need to remove the specific jar from your maven cache and re-build your application.
As you have already tried cleaning the m2
repository various times through clean install
but the error persists you may need to hard delete this particular jar and rebuild your application.
Outro
You can find a relevant discussion in:
专注分享java语言的经验与见解,让所有开发者获益!
评论