无法加载mojo'test'-org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test

时间:2018-11-08 16:23:16

标签: java maven maven-2 maven-3 maven-plugin

我正在用Maven-3构建我的应用程序,我想在将maven-surefire-plugin自动刷新为3.0.0-M1之后,我无法构建并得到以下错误。

作为第一步,我已经清除了存储库中的/ org / apache / maven目录,但是仍然面临该问题。任何人都可以建议。注意-如果我将surefire插件降级到2.x,则可以构建它。

错误日志

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.444s
[INFO] Finished at: Thu Nov 08 16:04:53 GMT 2018
[INFO] Final Memory: 60M/704M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test (default-test) on project TEST_PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1': com.google.inject.ProvisionException: Guice provision errors:
[ERROR] 
[ERROR] 1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
[ERROR] while locating org.apache.maven.plugin.surefire.SurefirePlugin
[ERROR] at ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test)
[ERROR] 
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test (default-test) on project TEST_PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1'
    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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1'
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.apache.maven.plugin.PluginContainerException: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1'
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:488)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
    ... 20 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Guice provision errors:

1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
  while locating org.apache.maven.plugin.surefire.SurefirePlugin
  at ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
  while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test)

1 error
      role: org.apache.maven.plugin.Mojo
  roleHint: org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
    ... 21 more
Caused by: com.google.inject.ProvisionException: Guice provision errors:

1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
  while locating org.apache.maven.plugin.surefire.SurefirePlugin
  at ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
  while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test)

1 error
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:974)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
    ... 23 more 

8 个答案:

答案 0 :(得分:8)

您可以将Maven版本升级到最新的3.6.0,以解决此问题。这可以从3.3.9 maven版本兼容。

答案 1 :(得分:6)

通过查看有关升级maven版本的评论,我们更新了maven版本,并能够使用maven 3.3.9克服surefire插件问题。没有任何问题。

答案 2 :(得分:4)

我发现我的NetBeans使用的是非常老的Maven(3.0.5),即使我安装了全新的Maven。

在Mac上,我必须转到菜单“ Netbeans / Preferences”,选择“ Maven”选项卡,然后从“ Bundled”更改为最新版本,这对我来说摆脱了上面的错误。

答案 3 :(得分:2)

我遇到了这个问题,直到发现我们没有明确指定surefire插件的版本。更改pom.xml文件以设置版本后,它就可以工作。

答案 4 :(得分:0)

我同意SomMS的回答

但是作为一个FYI,我发现了这个线程,立即驳斥了Maven版本可能是问题所在,因为我刚刚(上周)构建了这个RHEL VM,并且它是新的且有光泽 ... 15分钟后,我决定检查Maven版本以发现它是v3.0.5! 希望下一个家伙不会犯同样的错误

如果您想知道如何获取已安装内容的版本,请尝试

mvn --version

答案 5 :(得分:0)

我使用@SomMS的建议并升级了Maven以解决此问题。奏效了。

问题在于,在撰写本文时,CentOS 7上可用的Maven的最新版本是3.0.5(默认存储库),该版本确实很旧(2013年2月)。其他大多数发行版都可以使用较新的Maven版本。

我唯一的解决方案是手动下载并在PATH env-variable中将路径添加到其二进制文件。缺点是现在rpm / yum尚不知道它的存在。

答案 6 :(得分:0)

如果您在netbeans IDE中遇到问题,则需要更改默认的mavenhome版本。请按照以下步骤操作 在菜单栏工具->选项->单击Java选项卡->类别->执行-> Maven主页下拉列表中,选择手动安装的Maven位置

答案 7 :(得分:0)

您可以使用pluginManagement标记将maven-surefire-plugin的版本降级为2.12.4。它对我有用。