java - 执行 Maven 构建时缺少所需的类
问题描述
我在执行mvn clean install
命令时遇到了这个错误。我已经尝试过删除位于路径' file:/C:/Users/{user}/.m2/repository/org/apache/maven/plugins/ '下的相关插件的解决方案,但它没有解决问题。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (test) on project tr.com.aselsan.c2.cbs: Execution test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test: org/apache/maven/surefire/booter/KeyValueSource
[ERROR] realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.22.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/{user}/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.22.2/maven-surefire-plugin-2.22.2.jar
[ERROR] urls[1] = file:/C:/Users/{user}/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.22.2/maven-surefire-common-2.22.2.jar
[ERROR] urls[2] = file:/C:/Users/{user}/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[project>tr.com.aselsan:parent:2.0.0-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
[ERROR] : org.apache.maven.surefire.booter.KeyValueSource
这是 pom.xml 中的构建目标:
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
注意:问题仅发生在我的本地机器上,jenkins 触发的构建成功。
解决方案
推荐阅读
- office365 - 如何将我的订阅 office 365 business basic 连接到 Editor ADSI?
- node.js - 升级到 AnonymousTraversalSource (Gremlin 3.3.5+ Node.js)
- reactjs - 上传到 firebase:TypeError:uploadTask.on 不是函数
- javascript - 通过 UIKit 模式向数组添加元素在 vuejs 中不起作用
- scala - 执行捕获变量的嵌套函数分配
- kotlin - Kotlin 泛型类型不匹配
- kubernetes - 如何设置 Kubernetes 以支持动态添加的子域?
- excel - 交叉引用具有工作表编号的单元格
- elasticsearch - 查找日志文件的 grok 模式
- node.js - 在 node.js 类中找不到方法