java.lang.IllegalStateException : Failed to read Class-Path attribute from manifest of jar error using Selenium through Maven in Spring Boot

标签 java spring-boot selenium maven illegalstateexception

我在尝试配置 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)
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)

我多次尝试清理我的 m2 存储库并添加不同版本的依赖项,但似乎没有解决问题。我也尝试过使用全新安装,但如果我放置了 selenium 依赖项,它会显示构建错误。

最佳答案

此错误消息...

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

...意味着您的 Maven 缓存中的一个 jar 已损坏。

就您而言,以下文件似乎已损坏:

file:/C:/Users/Usuario/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
<小时/>

解决方案

您需要从 Maven 缓存中删除特定的 jar 并重新构建您的应用程序。

由于您已经尝试通过全新安装多次清理m2存储库,但错误仍然存​​在,您可能需要硬删除这个特定的jar 并重建您的应用程序。

<小时/>

片尾

您可以在以下位置找到相关讨论:

关于java.lang.IllegalStateException : Failed to read Class-Path attribute from manifest of jar error using Selenium through Maven in Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62106284/

相关文章:

Java FX "mass"处理按钮

java - 将各种类型的文档(ods、ms office、pdf)保存到 Jackrabbit 存储库中

spring-boot - Spring Boot排除了在Maven构建期间连接到数据库的问题

spring-boot - Spring Boot AMQP 无法进行 SSL 连接

java - 如何使用 junit 5 (Jupiter) 模拟 RestTemplate 交换

java - 如何使用 Selenium WebDriver 选择网页上的 2 个元素之一?

javascript - 让javascript强制Selenium测试失败

JavaFX - 其文本字段的 ComboBox 监听器

java - 如何使用 Selenium 查找元素

java - Future.get() 和 InterruptedException 异步线程