0

我的项目使用handlebars-proto 将模板绑定到json。另外我正在尝试使用logstash-logback-encoder 以Json 的形式登录logstash。以下是我的编译依赖项(以及其他依赖项)

   compile 'net.logstash.logback:logstash-logback-encoder:4.6'
   compile 'com.github.jknack:handlebars-proto:4.0.5'

如果我删除车把依赖记录工作正常。如果存在车把,我会收到以下警告:

SLF4J:类路径包含多个 SLF4J 绑定。SLF4J:在 [jar:file:/C:/Users/manish/.gradle/caches/modules-2/files-2.1/com.github.jknack/handlebars-proto/4.0.5/5979737344d99e0d8b482e828f247ae86fd0113/handlebars-proto 中找到绑定-4.0.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J:在 [jar:file:/C:/Users/manish/.gradle/caches/modules-2/files-2.1/ch 中找到绑定.qos.logback/logback-classic/1.1.6/665e3de72f19ec66ac67d82612d7b8e6b3de3cd0/logback-classic-1.1.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J:见http://www.slf4j.org/codes .html#multiple_bindings进行解释。

其次是错误:

无法实例化 [ch.qos.logback.classic.LoggerContext] 报告异常: java.lang.NoSuchMethodError: ch.qos.logback.core.spi.ContextAwareBase.(Lch/qos/logback/core/spi/ContextAware;)V 在 net.logstash.logback.composite.CompositeJsonFormatter.(CompositeJsonFormatter.java:106) 在 net.logstash.logback.composite.loggingevent.LoggingEventCompositeJsonFormatter.(LoggingEventCompositeJsonFormatter.java:28) 在 net.logstash.logback.LogstashFormatter.(LogstashFormatter. java:122) 在 net.logstash.logback.LogstashFormatter.(LogstashFormatter.java:118) 在 net.logstash.logback.LogstashFormatter.(LogstashFormatter.java:114) 在 net.logstash.logback.encoder.LogstashEncoder.createFormatter(LogstashEncoder .java:31) 在 net.logstash.logback.encoder.CompositeJsonEncoder.(CompositeJsonEncoder.java:48) 在 net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder.(LoggingEventCompositeJsonEncoder.java:23) 在 net.logstash.logback.encoder。位于 sun.reflect 的 LogstashEncoder.(LogstashEncoder.java:27)。NativeConstructorAccessorImpl.newInstance0(Native Method) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor. java:526) 在 java.lang.Class.newInstance(Class.java:379) 在 ch.qos.logback.core.joran.action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core .joran.spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi .Interpreter.startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)50)50)newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java: 526) 在 java.lang.Class.newInstance(Class.java:379) 在 ch.qos.logback.core.joran.action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core.joran .spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi.Interpreter .startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java: 526) 在 java.lang.Class.newInstance(Class.java:379) 在 ch.qos.logback.core.joran.action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core.joran .spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi.Interpreter .startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)newInstance(NativeConstructorAccessorImpl.java:57) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:526) 在 java.lang.Class.newInstance(Class .java:379) 在 ch.qos.logback.core.joran.action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) ) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) 在 ch。 qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)newInstance(NativeConstructorAccessorImpl.java:57) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:526) 在 java.lang.Class.newInstance(Class .java:379) 在 ch.qos.logback.core.joran.action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) ) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) 在 ch。 qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:379) at ch.qos.logback.core.joran .action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter .startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer .java:50)newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:379) at ch.qos.logback.core.joran .action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122) 在 ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter .startElement(Interpreter.java:148) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer .java:50)122) 在 ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch .qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)122) 在 ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) 在 ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) 在 ch .qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) 在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)

我尝试将 slf4j 排除为车把的传递依赖项,但它没有帮助。

compile
 ('com.github.jknack:handlebars-proto:4.0.5'){

 exclude module: 'slf4j-api' 

 }

提前感谢您的帮助。如果需要更多详细信息,请告诉我。

4

1 回答 1

0

错误消息是因为 handlebars-proto jar 包含 的实现org.slf4j.impl.StaticLoggerBinder,这意味着它具有日志记录实现。您还尝试添加自己的 Logback 日志记录实现,并且由于 SLF4J 不能同时使用两个日志记录系统,因此它在抱怨。

我对车把项目不熟悉,但我猜你那里的库是一个包含日志系统的完整应用程序,并不是真正设计为被另一个项目用作依赖项。也许有一个不同的版本可用,它只是库,并且不尝试包含自己的日志记录实现?

于 2016-06-02T17:55:13.983 回答