java - java.lang.IllegalStateException:无法在 Spring Boot 中使用 Selenium 通过 Maven 从 jar 错误清单中读取 Class-Path 属性
问题描述
在尝试配置 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
存储库,clean install
但错误仍然存在,您可能需要硬删除此特定jar并重建您的应用程序。
奥特罗
您可以在以下位置找到相关讨论:
推荐阅读
- python-multiprocessing - 使用 zmq 在多个进程之间进行通信
- c# - 如何在脚本中“复制世界放置”?
- excel - 将 http 获取请求图像转换为 Excel ActiveSheet.Pictures
- c - 为什么 valgrind 给我的内存泄漏错误的行位置?
- forms - windows.forms 和重绘位图
- reactjs - 在 React 中渲染 STL 文件
- swift - Empty() 发布者不发送完成
- regex - 如何为所有图像添加域
- javascript - 使用 HTTP Post(RESTful API)将请求从 React.JS 前端传递到 C# 后端(ASP.NET)
- php - 无法从表 php 中检索数据