执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test 失败

9

我正在尝试安装Stanbol,但出现以下错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test

附加错误日志
[INFO] 

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project org.apache.stanbol.entityhub.ldpath: There are test failures. [ERROR]  [ERROR] Please refer to /home/stanbol-trunk/entityhub/ldpath/target/surefire-reports for the individual test results.

[ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project org.apache.stanbol.entityhub.ldpath: There are test failures.

Please refer to /home/stanbol-trunk/entityhub/ldpath/target/surefire-reports for the individual test results.   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)  at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:606)     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to /home/stanbol-trunk/entityhub/ldpath/target/surefire-reports for the individual test results.   at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:82)  at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:254)   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:854)    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:722)     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)  ... 19 more

[ERROR] 

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

[ERROR] 

[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :org.apache.stanbol.entityhub.ldpath
6个回答

15

看起来你正在使用的库里有一些测试失败了。

如果你想了解测试错误的详细信息,可以查看 /home/stanbol-trunk/entityhub/ldpath/target/surefire-reports。

如果你仍想安装该库,可以运行 mvn clean install -DskipTests

希望对你有所帮助!


哦,对我有用。感谢这篇文章。 - Bhargav Patel
“-DskipTests”会跳过测试吗?如果是的话,我希望这不会对部署造成影响。 - Bhargav Patel
可以用。非常感谢! - Marslo

3

在项目上右键 -> "Run as Maven Test"。这将自动下载缺失的插件。然后,在项目上右键 -> "Update Maven project" 它会移除错误。


2

@SpringBootApplication 注解包含以下配置。

1) @Configuration

2) @ComponentScan

3) @EnableAutoConfiguration

@EnableAutoConfiguration 是这个错误的原因。它会根据 pom.xml 中的依赖项尝试自动配置应用程序。

例如,当您在 pom.xml 中有 spring-data-jpa 依赖项时,它会尝试通过查看 application.properties 文件中的数据源来为应用程序添加配置。因此,您需要添加数据源来解决该问题。

mvn clean install -DskipTests 将帮助您在解决错误之前跳过测试。


1
如果您在构建Maven项目时遇到上述问题,请尝试将以下代码放入您的pom.xml文件中。
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
        </plugins>
    </build>

可能出现问题的原因是surefire插件的版本不正确或未下载。

有趣的是,对我来说,将版本从2.20.1更改为最新的3.0.0-M1确实解决了Surefire插件报告崩溃的问题,这似乎与明显的测试失败无关。 - hello_earth

0

你可以在 pom.xml 文件中添加这些标签。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

有人能解释一下为什么它会被踩吗?提供了一个类似的答案,得到了赞成票。对未来的读者来说并不是很有用。这对我来说可以工作,但我想确保它是良好的设计。 - soulshined

0
此外,如果您更改了测试路径,则可能会出现此问题。在这种情况下,无法找到测试并因此无法执行。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接