我遇到了一系列文件与我的SBT构建文件冲突。我选择了两个错误,它们代表属性冲突和类冲突。
由sbt assembly
命令引起的错误,如下所示:
error] (util/*:assembly) deduplicate: different file contents found in the following:
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-codec-http/jars/netty-codec-http-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/lorancechen/.ivy2/cache/io.netty/netty-transport-native-epoll/jars/netty-transport-native-epoll-4.0.42.Final-linux-x86_64.jar:META-INF/io.netty.versions.properties
[error] deduplicate: different file contents found in the following:
[error] /Users/lorancechen/.ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.21.jar:org/apache/commons/logging/Log.class
[error] /Users/lorancechen/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/Log.class
它不是由库版本依赖性冲突引起的,而是因为不同的库具有以相同包路径命名的相同类或文件。
我有两个问题:
是否可以获取正确的文件以及如何在sbt构建文件中执行此操作?
Java项目应该遵循包命名空间定义。那么,为什么org.slf4j/jcl-over-slf4j
和commons-logging/commons-logging
的两个组织具有相同的类路径org/apache/commons/logging/Log.class
,而不是为org/slf4j/commons/logging/Log.class
org和{{1}定义为org.slf4j
} org/apache/commons/logging/Log.class
org?
此外,commons-logging
作为groupId的名称非常奇怪。
感谢。