在我的 quarkus java 应用程序中,启动时我从 slf4j 收到以下消息:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/.../quarkus-app/lib/main/org.jboss.slf4j.slf4j-jboss-logmanager-2.0.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/.../target/quarkus-app/lib/main/org.openpreservation.jhove.jhove-ext-modules-1.30.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Slf4jLoggerFactory]
SLF4J: The requested version 2.0.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
我的pom中这两个外部依赖项之间似乎存在冲突(此处缩短):
<dependency>
groupId>org.openpreservation.jhove</groupId>
<artifactId>jhove-ext-modules</artifactId>
<version>1.30</version>
</dependency>
<dependency>
<groupId>org.amqphub.quarkus</groupId>
<artifactId>quarkus-qpid-jms</artifactId>
<version>2.6.1</version>
</dependency>
我已经完成了
mvn dependency:tree -Dverbose -Dincludes="*.slf4j"
在 jhove-ext-modules 中找到 slf4j 实现:
[INFO] +- org.openpreservation.jhove:jhove-ext-modules:jar:1.30.0:compile
[INFO] | \- org.w3c:epubcheck:jar:5.1.0:compile
[INFO] | +- net.sf.saxon:Saxon-HE:jar:11.4:compile
[INFO] | | \- org.xmlresolver:xmlresolver:jar:4.4.3:compile
[INFO] | | \- org.apache.httpcomponents.client5:httpclient5:jar:5.1.3:runtime
[INFO] | | \- (org.slf4j:slf4j-api:jar:2.0.6:runtime - version managed from 1.7.25; omitted for duplicate)
[INFO] | +- com.jayway.jsonpath:json-path-assert:jar:2.8.0:compile
[INFO] | | +- com.jayway.jsonpath:json-path:jar:2.8.0:runtime
[INFO] | | | \- (org.slf4j:slf4j-api:jar:2.0.6:runtime - version managed from 1.7.36; omitted for duplicate)
[INFO] | | \- (org.slf4j:slf4j-api:jar:2.0.6:runtime - version managed from 1.7.36; omitted for duplicate)
[INFO] | \- org.slf4j:slf4j-nop:jar:1.7.36:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:2.0.6:compile - version managed from 1.7.36; omitted for duplicate)
并添加以下排除:
<dependency>
<groupId>org.openpreservation.jhove</groupId>
<artifactId>jhove-ext-modules</artifactId>
<version>${org.openpreservation.jhove.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>
但这并没有改变结果。另一个依赖项
qpid-jms
包含传递依赖项 org.jboss.slf4j:slf4j-jboss-logmanager:jar:2.0.0
。如果我为此添加排除项,那么应用程序将正常启动。但是我想保留日志输出的这种依赖性。
任何帮助或提示表示赞赏。
slf4j-api
和 logback-classic
。exclusions
和jhove-ext-modules
中添加quarkus-qpid-jms
。<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.15</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.openpreservation.jhove</groupId>
<artifactId>jhove-ext-modules</artifactId>
<version>1.30.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.amqphub.quarkus</groupId>
<artifactId>quarkus-qpid-jms</artifactId>
<version>2.6.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logmanager</artifactId>
</exclusion>
</exclusions>
</dependency>
我可以测试一下我自己的代码可以通过SLF4J输出日志文件,然后logback。
但是我没有您使用
jhove-ext-modules
或quarkus-qpid-jms
的相关代码,所以无法验证。 、jhove-ext-modules 或 quarkus-qpid-jms 都可以正常输入日志。
这部分必须由你自己的项目验证。