1

当我尝试运行 mvn clean install -P embedded 时出现以下错误,我以前从未使用过 Maven,实际上几乎不明白它试图告诉我什么。有人可以帮我解决吗?

    [FATAL ERROR] org.apache.maven.plugin.clean.CleanMojo#execute() caused a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check the realms:
[FATAL ERROR] Plugin realm = app0.child-container[org.apache.maven.plugins:maven-clean-plugin:2.2]
urls[0] = file:/Users/andrejcek/.m2/repository/org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.jar
urls[1] = file:/Users/andrejcek/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
urls[2] = file:/Users/andrejcek/.m2/repository/org/apache/maven/shared/file-management/1.2/file-management-1.2.jar
urls[3] = file:/Users/andrejcek/.m2/repository/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.jar
[FATAL ERROR] Container realm = plexus.core
urls[0] = file:/usr/share/maven/lib/maven-2.2.0-uber.jar
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org/apache/maven/shared/io/logging/MessageSink
org.apache.maven.shared.io.logging.MessageSink
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoClassDefFoundError: org/apache/maven/shared/io/logging/MessageSink
    at org.apache.maven.plugin.clean.CleanMojo.execute(CleanMojo.java:171)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
    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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.shared.io.logging.MessageSink
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
    at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
    at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
    ... 20 more
4

3 回答 3

1

我遇到了同样的问题,但后来我找到了非常简单的解决方案。

step1 - 从http://maven.apache.org/download.cgi下载所需的 maven 文件夹(我已经下载了 Maven 2.2.1 (Binary tar.gz))

第 2 步 - 提取 tar 并将文件夹放到您想要的位置(即 /usr/lib/)

step3 - 更新你使用它的maven路径(在我的例子中是.bashrc)

基本上问题是您的 Maven 已损坏,您需要按照上述步骤来解决它。:)

于 2014-02-04T09:31:33.600 回答
0

检查您是否正确设置了 M2_HOME 变量,如安装说明中所述。

于 2012-08-21T10:54:30.747 回答
0

您的 Maven 安装已损坏。卸载它,重新下载 maven,确认 md5 校验和匹配,安装它并重试。

类似的问题线程

编辑:另一种选择是您从损坏的回购中下载了一些东西。如果重新安装 maven 不能解决问题,请检查您是否使用了有问题的存储库(最好在此处报告您配置的 pom 依赖项)。也有过这样的案例

于 2012-08-21T10:45:53.757 回答