maven项目编译时jar包冲突相关问题

从开源代码上拷下来一个源码学习,执行mvn clean install时报错:
[WARNING] Error injecting: aQute.bnd.maven.plugin.BndMavenPlugin
java.lang.NoClassDefFoundError: org/codehaus/plexus/util/Scanner
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getDeclaredConstructors(Class.java:2020)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:658)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:882)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:805)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:282)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:214)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:1006)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1038)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1001)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53)
at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:65)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
........
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.util.Scanner
........
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.616 s
[INFO] Finished at: 2017-11-20T15:08:13+08:00
[INFO] Final Memory: 17M/201M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal biz.aQute.bnd:bnd-maven-plugin:3.1.0:bnd-process (default) on project gson: Execution default of goal biz.aQute.bnd:bnd-maven-plugin:3.1.0:bnd-process failed: A required class was missing while executing biz.aQute.bnd:bnd-maven-plugin:3.1.0:bnd-process: org/codehaus/plexus/util/Scanner
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>biz.aQute.bnd:bnd-maven-plugin:3.1.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/dasouche/.m2/repository/biz/aQute/bnd/bnd-maven-plugin/3.1.0/bnd-maven-plugin-3.1.0.jar
[ERROR] urls[1] = file:/Users/dasouche/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] urls[2] = file:/Users/dasouche/.m2/repository/biz/aQute/bnd/biz.aQute.bndlib/3.1.0/biz.aQute.bndlib-3.1.0.jar
[ERROR] urls[3] = file:/Users/dasouche/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : org.codehaus.plexus.util.Scanner
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

在项目的pom.xml文件中添加jar包依赖明确版本号:

org.codehaus.plexus
plexus-utils
3.0.5

依然报上面的错误。

请问各位大神这个是什么问题,怎么解决?

1个回答

错误里说找不到这个类:org.codehaus.plexus.util.Scanner,你加的那个版本里面可能没有这个类。你可以解压了看看有没有。或者试试更高或更低的版本(这个类可能在更高的版本中被删除了或者在更高的版本中才添加的)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!