【发布时间】:2020-10-28 10:14:22
【问题描述】:
我不知道为什么会这样。我也尝试删除我的 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 插件作为依赖项是完全错误的。而是在 pluginManagement 中定义一个插件。同时显示你使用的命令,以及你使用的 JDK 版本、Maven 版本等。
-
我不需要 maven 插件,所以我删除了它。我正在使用 mvn dependency:tree 、 jdk 11.0.5 和 maven 3.5.4
-
您使用了哪个版本的 maven-dependency-plugin,因为它不是错误输出的一部分...通常会被注销...最好使用
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:tree来确定使用最新版本的插件....
标签: java spring-boot maven sonatype maven-dependency-plugin