首页 > 解决方案 > 执行 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 触发的构建成功。

标签: javamavenmaven-surefire-plugin

解决方案


推荐阅读