我们在gradle面临着sl4j版本与storm 1.0.1和elasticsearch 5.2的冲突。
我们发现elasticsearch需要桥接log4j-to-slf4j,以便使用所需的记录器。在这里,我们试图使用经典的logback与slf4j。
相关性定义如下:
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.apache.logging.log4j:log4j-to-slf4j:2.6.2'
compile 'ch.qos.logback:logback-classic:1.1.10'
provided ('org.apache.storm:storm-core:1.0.1') {
exclude(group: 'org.slf4j', module: 'slf4j-api')
}
compile 'org.elasticsearch:elasticsearch:5.2.0'
compile 'org.elasticsearch.client:x-pack-transport:5.2.0'
}
为了解决这个问题,我尝试从storm core中排除slf4j,并在稍后添加相同的内容,如下所示:
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails dependencyResolveDetails ->
final requestedDependency = dependencyResolveDetails.requested
if (requestedDependency.group == 'org.slf4j' && requestedDependency.name == 'slf4j-api') {
requestedDependency.setVersion "1.7.7"
}
}
}
}
但是当提交拓扑时,我们得到错误:slf4j:class path包含多个slf4j绑定。slf4j:在中找到绑定[jar:file:/users/gauthamr05/documents/apps/storm/apache-storm-1.0.1/lib/log4j-slf4j-impl-2.1.jar/org/slf4j/impl/staticloggerbinder.class]slf4j:在中找到绑定[jar:file:/users/gauthamr05/documents/workspace/xyz\u app/build/libs/fullindex.jar/org/slf4j/impl/staticloggerbinder.class]slf4j:请参阅http://www.slf4j.org/codes.html#multiple_bindings 为了解释。slf4j:实际绑定的类型为[org.apache.logging.slf4j.log4jloggerfactory]exception,位于org.apache.logging.log4j.spi.loggerregistry.getorcreateinnermap(loggerregistry)的线程“main”java.lang.stackoverflowerr中。java:140)在org.apache.logging.log4j.spi.loggerregistry.haslogger(loggerregistry。java:154)在org.apache.logging.slf4j.slf4jloggercontext.getlogger(slf4jloggercontext)。java:38)在org.apache.logging.slf4j.log4jloggerfactory.newlogger(log4jloggerfactory。java:37)在org.apache.logging.slf4j.log4jloggerfactory.newlogger(log4jloggerfactory。java:29)在org.apache.logging.log4j.spi.abstractloggeradapter.getlogger(abstractloggeradapter。java:47)在org.apache.logging.slf4j.log4jloggerfactory.getlogger(log4jloggerfactory)。java:29)在org.slf4j.loggerfactory.getlogger(loggerfactory。java:277)
2条答案
按热度按时间fivyi3re1#
例外情况是,有两个jar包含
StaticLoggerBinder.class
./users/gauthamr05/documents/apps/storm/apache-storm-1.0.1/lib/log4j-slf4j-impl-2.1.jar
/users/gauthamr05/documents/workspace/xyz\u app/build/libs/fullindexing.jar
问题:是吗
xyz_app/build/libs/FullIndexing.jar
你自己的项目?如果这是你自己的jar,我猜一下,但我猜是的
org/slf4j/impl/StaticLoggerBinder.java
在类路径上的一个jar里。有一个wierd默认值javac
它将编译任何.java
在类路径的jar中找到的文件。可通过以下方式关闭看到这里和这里了吗
fzsnzjdm2#
找到了在最终jar中隐藏log4j类的方法。
以下是配置: