我有一个依赖于其他两个项目的模块,但是在使用。
构建项目时我得到了这个虽然没有错误,但我收到很多关于重叠同一个班级的警告:
[WARNING] commons-logging-1.2.jar, jcl-over-slf4j-1.7.12.jar define 6 overlappping classes:
[WARNING] - org.apache.commons.logging.impl.SimpleLog$1
[WARNING] - org.apache.commons.logging.Log
[WARNING] - org.apache.commons.logging.impl.SimpleLog
[WARNING] - org.apache.commons.logging.LogConfigurationException
[WARNING] - org.apache.commons.logging.impl.NoOpLog
[WARNING] - org.apache.commons.logging.LogFactory
[WARNING] aspectjrt-1.7.0.jar, aspectjweaver-1.8.6.jar define 128 overlappping classes:
[WARNING] - org.aspectj.internal.lang.reflect.SignaturePatternImpl
[WARNING] - org.aspectj.runtime.reflect.SignatureImpl
[WARNING] - org.aspectj.internal.lang.reflect.DeclareSoftImpl
[WARNING] - org.aspectj.lang.reflect.AjType
[WARNING] - org.aspectj.lang.JoinPoint$StaticPart
[WARNING] - org.aspectj.runtime.internal.cflowstack.ThreadStackImpl11
[WARNING] - org.aspectj.runtime.internal.cflowstack.ThreadStack
[WARNING] - org.aspectj.internal.lang.reflect.InterTypeDeclarationImpl
[WARNING] - org.aspectj.internal.lang.reflect.DeclareAnnotationImpl
[WARNING] - org.aspectj.lang.annotation.SuppressAjWarnings
[WARNING] - 118 more...
[WARNING] maven-shade-plugin has detected that some .class files
[WARNING] are present in two or more JARs. When this happens, only
[WARNING] one single version of the class is copied in the uberjar.
[WARNING] Usually this is not harmful and you can skeep these
[WARNING] warnings, otherwise try to manually exclude artifacts
[WARNING] based on mvn dependency:tree -Ddetail=true and the above
[WARNING] output
[WARNING] See http://docs.codehaus.org/display/MAVENUSER/Shade+Plugin
[INFO] Replacing original artifact with shaded artifact.
我该如何避免这些警告?
答案 0 :(得分:1)
使用Maven plugin Dependency Tree,并使用
执行此操作clean
target
对于避免旧dependency-tree
内容的任何副作用非常重要。
然后,根据您使用的插件,您可以像this answer中一样添加排除规则,以避免出现这些错误消息。
如MRUNIT-209所示,org.apache.maven.plugins:maven-dependency-plugin:3.0.1:tree
的2.5.1版本无法与Maven 3.x.x一起运行。
使用全名true
将强制使用maven-dependency-plugin的3.0.1版本。