Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java surefire插件在maven中的测试阶段异常_Java_Maven_Plugins_Surefire - Fatal编程技术网

Java surefire插件在maven中的测试阶段异常

Java surefire插件在maven中的测试阶段异常,java,maven,plugins,surefire,Java,Maven,Plugins,Surefire,我需要使用surefire v2.12,但每次运行该版本时都会得到附加的堆栈跟踪。如果我运行v2.10,我不会得到错误。我需要这个版本,这样我就可以用@Category注释我的测试类,并将它们标记为UnitTests或IntegrationTests。 这是我的命令:mvn test-Dsurefire.version=2.12-X [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12

我需要使用surefire v2.12,但每次运行该版本时都会得到附加的堆栈跟踪。如果我运行v2.10,我不会得到错误。我需要这个版本,这样我就可以用@Category注释我的测试类,并将它们标记为UnitTests或IntegrationTests。 这是我的命令:mvn test-Dsurefire.version=2.12-X

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null: ExceptionInInitializerError: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project ASPEN: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 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:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:197) at org.apache.maven.surefire.util.ReflectionUtils.invokeGetter(ReflectionUtils.java:69) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.getSuites(ProviderFactory.java:148) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.getSuitesIterator(ForkStarter.java:317) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:149) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:118) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:199) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:176) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) ... 30 more Caused by: java.lang.ExceptionInInitializerError ... 2 more at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.junit.runner.Description.getTestClass(Description.java:207) at org.apache.maven.surefire.common.junit48.FilterFactory$GroupMatcherCategoryFilter.shouldRun(FilterFactory.java:207) at org.apache.maven.surefire.junitcore.JUnitCoreProvider.getSuitesAsList(JUnitCoreProvider.java:169) at org.apache.maven.surefire.junitcore.JUnitCoreProvider.getSuites(JUnitCoreProvider.java:102) ... 35 more Caused by: java.lang.RuntimeException: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' ... 12 more (deleted lines here) [错误]未能执行目标org.apache.maven.plugins:maven surefire插件:2.12:test(默认测试)对项目:执行目标org.apache.maven.plugins的默认测试:maven surefire插件:2.12:test失败:java.lang.reflect.InvocationTargetException;嵌套异常为java.lang.reflect.InvocationTargetException:null:ExceptionInInitializeError:Unexpected ClassNotFoundException查找类“org.apache.maven.cli.MavenCli”->[帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:未能执行目标org.apache.maven.plugins:maven surefire插件:2.12:test(默认测试)对项目ASPEN:Execution默认测试目标org.apache.maven.plugins:maven surefire插件:2.12:test失败:java.lang.reflect.InvocationTargetException;嵌套异常为java.lang.reflect.InvocationTargetException:null 位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 位于org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 位于org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 位于org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 位于org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)上 位于org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 位于org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 位于org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中 位于java.lang.reflect.Method.invoke(Method.java:597) 位于org.codehaus.plexus.classworlds.launcher.launcher.launchEnhanced(launcher.java:290) 位于org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:230) 位于org.codehaus.plexus.classworlds.launcher.launcher.mainWithExitCode(launcher.java:409) 位于org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:352) 原因:org.apache.maven.plugin.PluginExecutionException:目标org.apache.maven.plugins:maven surefire插件执行默认测试:2.12:测试失败:java.lang.reflect.InvocationTargetException;嵌套异常为java.lang.reflect.InvocationTargetException:null 位于org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) 位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 还有19个 原因:org.apache.maven.surefire.util.SurefireReflectionException:java.lang.reflect.InvocationTargetException;嵌套异常为java.lang.reflect.InvocationTargetException:null 位于org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:197) 位于org.apache.maven.surefire.util.ReflectionUtils.invokeGetter(ReflectionUtils.java:69) 位于org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.getSuites(ProviderFactory.java:148) 位于org.apache.maven.plugin.surefire.booterclient.ForkStarter.getSuitesIterator(ForkStarter.java:317) 位于org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:149) 位于org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:118) 位于org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:199) 位于org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:176) 位于org.apache.maven.plugin.surefire.AbstractSurefireMojo.ExecuteAfterPremissionSchecked(AbstractSurefireMojo.java:135) 位于org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98) 位于org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20多 原因:java.lang.reflect.InvocationTargetException 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中 位于java.lang.reflect.Method.invoke(Method.java:597) 位于org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) ... 30多 原因:java.lang.ExceptionInInitializeError ... 还有两个 位于java.lang.Class.forName0(本机方法) 位于java.lang.Class.forName(Class.java:169) 位于org.junit.runner.Description.getTestClass(Description.java:207) 位于org.apache.maven.surefire.common.junit48.FilterFactory$GroupMatcherCategoryFilter.shouldRun(FilterFactory.java:207) 位于org.apache.maven.surefire.junitcore.junitpreprovider.getSuitesAsList(junitprevider.java:169) 位于org.apache.maven.surefire.junitcore.junitpreprovider.getSuites(junitprevider.java:102) ... 35多 导致:java.lang.RuntimeException:查找类“org.apache.maven.cli.MavenCli”时出现意外的ClassNotFoundException ... 还有12个 (此处删除了行) 我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>sample</artifactId>
    <groupId>sample</groupId>
    <version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>webapp</artifactId>
<packaging>war</packaging>
<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.0</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>
</dependencies>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.5.1</version>
        </plugin>
    </plugins>
</reporting>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>${surefire.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <configuration>
                <groups>com.webapp.api.annotation.type.${group.include}</groups>
                <excludedGroups>com.webapp.api.annotation.type.${group.exclude}</excludedGroups>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

样品
样品
1.
INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.soebes.katas:code:1.0-SNAPSHOT (/home/katas/pom.xml) has 1 error
[ERROR]     'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin must be a valid version but is '${surefire.version}'. @ line 36, column 20
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/ProjectBuildingException