Java 无法加载 mojo 'test' - org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53211941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to load the mojo 'test' - org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test
提问by NGBeginner
I am building my apps with Maven-3 and i guess after auto-refresh of maven-surefire-plugin to 3.0.0-M1 i am not able to do build and getting the below error.
我正在使用 Maven-3 构建我的应用程序,我猜在将 maven-surefire-plugin 自动刷新到 3.0.0-M1 后,我无法进行构建并出现以下错误。
As a initial step, I have cleared the directory /org/apache/maven in my repository however still i am facing the issue. Can anyone advise. Note - if i am downgrading the surefire plugin to 2.x then I am able to build it.
作为第一步,我已经清除了存储库中的目录 /org/apache/maven 但是我仍然面临这个问题。任何人都可以建议。注意 - 如果我将 surefire 插件降级到 2.x,那么我就可以构建它。
Error log
错误日志
[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.get(InjectorImpl.java:974)
at com.google.inject.Scopes.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
采纳答案by SomMS
You can upgrade your maven version to 3.6.0 latest to solve this issue. This can be compatible from 3.3.9 maven version.
您可以将您的 maven 版本升级到最新的 3.6.0 来解决这个问题。这可以从 3.3.9 maven 版本兼容。
回答by Supun Malinga
Looking at the comments on upgrading maven version, we updated our maven version and was able to overcome the surefire plugin issue using maven 3.3.9. Didn't get any issues.
查看有关升级 maven 版本的评论,我们更新了 maven 版本,并能够使用 maven 3.3.9 克服 surefire 插件问题。没有遇到任何问题。
回答by whomer
I had this problem until I discovered that we were not explicitly specifying the version of the surefire plugin. Once I changed our pom.xml file to set the version, it worked.
我遇到了这个问题,直到我发现我们没有明确指定surefire插件的版本。一旦我更改了 pom.xml 文件以设置版本,它就起作用了。
回答by TWitt
I found that my NetBeans was using a very old maven (3.0.5) even though I had a brand new maven installed.
我发现我的 NetBeans 使用的是一个非常旧的 maven (3.0.5),即使我安装了一个全新的 maven。
On my Mac, I had to go to the menu "Netbeans/Preferences", select the "Maven" tab, and change from "Bundled", browsed to latest, and this got rid of the error above for me.
在我的 Mac 上,我必须转到菜单“Netbeans/Preferences”,选择“Maven”选项卡,然后从“Bundled”更改,浏览到最新,这为我解决了上面的错误。
回答by Patrick Cakes
I agree with SomMS's answer
我同意 SomMS 的回答
But as an FYI, I found this thread, immediately dismissed that maven version could be the problem the as I just (last week) built this RHEL VM and it was new and shiny ... 15 minutes later I decided to check the maven version to find it was v3.0.5! Hopefully the next guy doesn't make the same mistake
但是作为仅供参考,我发现了这个线程,立即驳回了 maven 版本可能是问题,因为我(上周)刚刚构建了这个 RHEL VM,它是新的和闪亮的...... 15 分钟后我决定检查 maven 版本发现它是v3.0.5!希望下一个人不要犯同样的错误
And if you are wondering how to get the version of whats installed try
如果您想知道如何获取已安装的版本,请尝试
mvn --version
回答by Radu Murzea
I used @SomMS's suggestion and upgraded Maven in order to fix the issue. It worked.
我使用了@SomMS 的建议并升级了 Maven 以解决该问题。有效。
The problem is that, at the time of this writing, the latest version of Maven available on CentOS 7 is 3.0.5 (default repository), which is really old (Feburary 2013). Most other distros have way newer Maven versions available to them.
问题是,在撰写本文时,CentOS 7 上可用的最新 Maven 版本是 3.0.5(默认存储库),它确实很旧(2013 年 2 月)。大多数其他发行版都有更新的 Maven 版本可供他们使用。
My only solution was to do a manual download and add path to its binary in PATH
env-variable. Downside here is that now rpm/yum are not aware of its existence.
我唯一的解决方案是手动下载并在环境PATH
变量中添加其二进制文件的路径。这里的缺点是现在 rpm/yum 不知道它的存在。
回答by user3894256
If you are facing the issue in netbeans IDE you need to change default mavenhome version.follow the below steps in menu bar tools->Options->click java tab --> under categories --> Execution --> Maven home drop down select manually installed location of the maven
如果您在 netbeans IDE 中遇到此问题,您需要更改默认的 mavenhome 版本。按照菜单栏工具->选项->单击 java 选项卡 --> 在类别下 --> 执行 --> Maven 主页下拉选择中的以下步骤手动安装maven的位置