当前位置: 首页 > 知识库问答 >
问题:

Maven构建失败,错误消息为无法执行目标组织。阿帕奇。专家插件:maven surefire插件:2.12。4:测试(默认测试)

洪伟兆
2023-03-14

我在尝试用Maven“清理安装”Spring项目时遇到了这个错误。

下面是"maven-surefire-plugin"的部分

<!-- BEGIN: Specific to mapping unit tests and covered code -->
<profiles>
    <profile>
        <id>coverage-per-test</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                    <configuration>
                        <forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
                        <forkMode>always</forkMode>
                        <reportFormat>plain</reportFormat>
                        <trimStackTrace>false</trimStackTrace>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.sonar.java.jacoco.JUnitListener</value>
                            </property>
                        </properties>
                    </configuration>
                </plugin>
            </plugins>
        </build>

        <dependencies>
            <dependency>
                <groupId>org.codehaus.sonar-plugins.java</groupId>
                <artifactId>sonar-jacoco-listeners</artifactId>
                <version>1.2</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>
<!-- END: Specific to mapping unit tests and covered code -->

下面是错误:

[信息]生成失败

[ERROR]未能执行目标org.apache.maven.plugins: maven-surefire-plugin: 2.12.4: test(default-test)on project copic-jpa2ddl:有测试失败。

[ERROR]未能执行目标org.apache.maven.plugins: maven-surefire-plugin: 2.12.4: test(default-test)on project copic-jpa2ddl:有测试失败。

[错误]-

[错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。

[错误]使用-X开关重新运行Maven以启用完整调试日志记录。

[错误]有关错误和可能的解决方案的更多信息,请阅读以下文章:

[错误][帮助1]http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.697 sec
Running com.teamwill.common.jpa2ddl.Jpa2DDLTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.011 sec <<< FAILURE!
initializationError(com.teamwill.common.jpa2ddl.Jpa2DDLTest)  Time elapsed: 0.005 sec  <<< ERROR!
java.lang.NoClassDefFoundError: org/eclipse/aether/RepositorySystemSession
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:18)
    at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:10)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:250)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.ClassNotFoundException: org.eclipse.aether.RepositorySystemSession
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 23 more


Results :

Tests in error: 
  initializationError(com.teamwill.common.jpa2ddl.Jpa2DDLTest): org/eclipse/aether/RepositorySystemSession

共有1个答案

南宫建白
2023-03-14

尝试执行下面的命令,以便Maven纠正所有依赖项及其verisons mvn依赖项:树。这在类似的问题中得到了解决。

 类似资料: