我有一个错误“类路径包含多个SLF4J绑定。”启动我的网络应用服务器时。我在这里找到的解决方案似乎没有用。我已经从域中排除了工件,但我仍然得到错误。我不明白为什么即使在排除后我也有错误。我正在使用Glassfish 4.1.1作为服务器。
Severe: SLF4J: Class path contains multiple SLF4J bindings.
Severe: SLF4J: Found binding in [jar:file:/C:/glassfish4.1.1/glassfish/domains/domain1/eclipseApps/csbasement/WEB-INF/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
Severe: SLF4J: Found binding in [jar:file:/C:/glassfish4.1.1/glassfish/domains/domain1/eclipseApps/csbasement/WEB-INF/lib/slf4j-simple-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
Severe: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
我排除了错误代码中提供的链接中显示的工件:
<!-- slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
MVN:树:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ maventest ---
[INFO] maventest:maventest:jar:0.0.1-SNAPSHOT
[INFO] +- org.omnifaces:omnifaces:jar:2.1:compile
[INFO] +- org.webjars:font-awesome:jar:4.4.0:compile
[INFO] +- org.ocpsoft.rewrite:rewrite-servlet:jar:2.0.12.Final:compile
[INFO] +- org.ocpsoft.rewrite:rewrite-config-prettyfaces:jar:2.0.12.Final:compile
[INFO] | +- org.ocpsoft.rewrite:rewrite-annotations-impl:jar:2.0.12.Final:compile
[INFO] | | +- org.ocpsoft.rewrite:rewrite-api:jar:2.0.12.Final:compile
[INFO] | | | +- org.ocpsoft.common:common-api:jar:1.0.5.Final:compile
[INFO] | | | \- org.ocpsoft.logging:logging-api:jar:1.0.2.Final:compile
[INFO] | | +- org.ocpsoft.rewrite:rewrite-api-servlet:jar:2.0.12.Final:compile
[INFO] | | | \- org.ocpsoft.rewrite:rewrite-addressbuilder:jar:2.0.12.Final:compile
[INFO] | | \- org.ocpsoft.rewrite:rewrite-annotations-api:jar:2.0.12.Final:compile
[INFO] | \- org.ocpsoft.rewrite:rewrite-integration-faces:jar:2.0.12.Final:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.primefaces:primefaces:jar:5.3:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- org.twitter4j:twitter4j-core:jar:4.0.4:compile
[INFO] +- org.twitter4j:twitter4j-stream:jar:4.0.4:compile
[INFO] +- com.twitter:hbc-core:jar:2.2.0:compile
[INFO] | +- com.twitter:joauth:jar:6.0.2:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.12:compile
[INFO] +- org.jsoup:jsoup:jar:1.8.2:compile
[INFO] +- com.ocpsoft:ocpsoft-pretty-time:jar:1.0.7:compile
[INFO] +- jstl:jstl:jar:1.2:compile
[INFO] \- com.google.code.gson:gson:jar:2.3.1:compile
这里是我的整个pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>maventest</groupId>
<artifactId>maventest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- omnifaces -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.1</version>
</dependency>
<!-- font awesome -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.12.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>2.0.12.Final</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<!-- twitter -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>hbc-twitter4j</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>hbc-core</artifactId> <!-- or hbc-twitter4j -->
<version>2.2.0</version> <!-- or whatever the latest version is -->
</dependency>
<!-- slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
答案 0 :(得分:1)
You are building .jar
, and usually if a .jar
is not a end-point standalone application (i.e. that you are usually start with java -jar myjar.jar
, while you are adding it as another dependency into a war
web application), you should not include slf4j implementations. So, just delete the slf4j-simple
dependency.