When I am trying to run mvn dependency:tree , I am getting : java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
When I am trying to run mvn dependency:tree , I am getting : java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
我不知道为什么会这样。我也尝试删除我的 m2 存储库。
我也尝试过各种版本的 maven 插件 (2.8)。
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
</dependency>
这是完整的堆栈跟踪:
Error injecting: org.apache.maven.shared.dependency.graph.internal.Maven3DependencyGraphBuilder
java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies
(ConstructorBindingImpl.java:181)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.version.VersionConstraint
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
更新 Maven 版本,至少到 3.0.x+ 或 3.1.x+ see here
This error is caused by Maven 3.1-alpha-1 migration from Sonatype
Aether to Eclipse Aether (MNG-5354), which is an incompatible change
for some plugins.
其他报告here claim to use Maven 3.3.0, so in any case, try with latest stable maven first (you can get it from here)
附带问题:您正在开发 maven 插件吗?通常你不应该在 pom.xml
中声明对插件的依赖
您可以使用旧版本的插件来解决,如错误日志中 official page 所示:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:tree
我不知道为什么会这样。我也尝试删除我的 m2 存储库。
我也尝试过各种版本的 maven 插件 (2.8)。
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
</dependency>
这是完整的堆栈跟踪:
Error injecting: org.apache.maven.shared.dependency.graph.internal.Maven3DependencyGraphBuilder
java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies
(ConstructorBindingImpl.java:181)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.version.VersionConstraint
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
更新 Maven 版本,至少到 3.0.x+ 或 3.1.x+ see here
This error is caused by Maven 3.1-alpha-1 migration from Sonatype Aether to Eclipse Aether (MNG-5354), which is an incompatible change for some plugins.
其他报告here claim to use Maven 3.3.0, so in any case, try with latest stable maven first (you can get it from here)
附带问题:您正在开发 maven 插件吗?通常你不应该在 pom.xml
中声明对插件的依赖您可以使用旧版本的插件来解决,如错误日志中 official page 所示:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:tree