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

天涯浪子 提交于 2019-11-29 19:09:24

问题


I am trying to install stanbol and getting the following error

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

Attaching the error log

[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

回答1:


It looks like you have some tests broken in the lib you are using.

Look at /home/stanbol-trunk/entityhub/ldpath/target/surefire-reports if you want details of the test errors.

If you want to install the lib anyway you can run mvn clean install -DskipTests

Hope it helps!




回答2:


Right Click on project -> "Run as Maven Test". This will automatically download the missing plugin. & after that, Right Click on project ->"Update Maven project" it removes the error




回答3:


@SpringBootApplication annotation contains these configurations.

1) @Configuration

2) @ComponentScan

3) @EnableAutoConfiguration

@EnableAutoConfiguration is the reason for this error. This will try to automatically configure application according to dependencies in your pom.xml

As a example when you have spring-data-jpa dependency in pom it will try to add configuration to application by looking at application.properties file for data source. So you need add data source to solve that.

mvn clean install -DskipTests will help you to skip testing until you solve the error.




回答4:


If You are facing above problem while building your maven project. Then please try to put below code in you pom.xml file.

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

Problem might be occurring because version of surefire plugin might be incorrect or not downloaded.




回答5:


Also, this issue may occur if you changed the path to your tests. In that case, the tests cannot be found and therefore executed.




回答6:


You can add these tag in 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>


来源:https://stackoverflow.com/questions/31221182/failed-to-execute-goal-org-apache-maven-pluginsmaven-surefire-plugin2-18-1tes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!