web-dev-qa-db-ja.com

mojo 'test'をロードできません-org.Apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test

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 
12
NGBeginner

この問題を解決するには、Mavenバージョンを最新の3.6.0にアップグレードします。これは、3.3.9 Mavenバージョンと互換性があります。

10
SomMS

Mavenバージョンのアップグレードに関するコメントを見て、Mavenバージョンを更新し、maven 3.3.9を使用してsurefireプラグインの問題を克服することができました。問題は発生しませんでした。

6
Supun Malinga

新しいMavenがインストールされていても、NetBeansは非常に古いMaven(3.0.5)を使用していることがわかりました。

私のMacでは、メニューの「Netbeans/Preferences」に移動し、「Maven」タブを選択して、「Bundled」から最新のブラウザに変更する必要がありました。これで上記のエラーがなくなりました。

5
TWitt

Surefireプラグインのバージョンを明示的に指定していないことが判明するまで、この問題がありました。バージョンを設定するためにpom.xmlファイルを変更すると、機能しました。

3
whomer

SomMSの答えに同意します

しかし、参考までに、私はこのスレッドを見つけて、先週私がこのRHEL VMを作成したばかりで、それが新しくて光沢があったので、Mavenバージョンが問題になる可能性があることをすぐに却下しました... 15分後に私はMavenバージョンをチェックして、v3.0.5であることがわかりました!うまくいけば、次の人は同じ間違いをしない

そして、インストールされているもののバージョンを取得する方法を知りたい場合は試してください

mvn --version
0
Patrick Cakes

@SomMSの提案を使用し、Mavenをアップグレードして問題を修正しました。動いた。

問題は、この記事の執筆時点で、CentOS 7で利用可能なMavenの最新バージョンが3.0.5(デフォルトリポジトリ)であり、これが非常に古いことです(2013年2月)。他のほとんどのディストリビューションには、新しいMavenバージョンがあります。

私の唯一の解決策は、手動ダウンロードを行い、PATH env-variableのバイナリにパスを追加することでした。ここでの欠点は、現在rpm/yumがその存在を認識していないことです。

0
Radu Murzea