0
在我的應用程序中有兩個日誌文件(org/slf4j/impl/StaticLoggerBinder.class
)的綁定。請看下圖:無法從類路徑中刪除logback
SLF4J: Found binding in [jar:file:/C:/Users/n12017/.m2/repository/ch/qos/logback/logback-classic/1.1.9/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/n12017/.m2/repository/cosine-lsh/cosinelsh/1.0/cosinelsh-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
下面我試圖從類路徑中刪除的logback:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<exclusions>
<exclusion>
<groupId>logback-classic</groupId>
<artifactId>ch.qos.logback</artifactId>
</exclusion>
</exclusions>
</dependency>
我也試圖從相關的依賴排除:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
不過,我有失敗。我怎樣才能刪除logback?
這裏是在依賴樹中的相關部分:
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.1.RELEASE:compile
[INFO] | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.11:compile
[INFO] | | \- org.apache.tomcat:tomcat-juli:jar:8.5.11:compile
[INFO] | \- org.springframework:spring-jdbc:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:4.2.1.RELEASE:compile
[INFO] | | \- org.springframework.security:spring-security-core:jar:4.2.1.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:4.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.6.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:1.5.1.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.1.RELEASE:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile
[INFO] | | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile
[INFO] | | +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile
[INFO] | | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | | \- com.fasterxml:classmate:jar:1.3.3:compile
[INFO] | | \- org.springframework:spring-webmvc:jar:4.3.6.RELEASE:compile
[INFO] | +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile
[INFO] | \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] | \- org.codehaus.groovy:groovy:jar:2.4.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.1.RELEASE:compile
[INFO] | +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] | | \- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] | +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] | \- org.slf4j:log4j-over-slf4j:jar:1.7.22:compile
在此先感謝。
謝謝@Andy Wilkinson!當我嘗試ch.qos.logback時出現如下錯誤:線程「main」中的異常java.lang.StackOverflowError \t at org.slf4j.impl.Log4jLoggerFactory.getLogger ....您的第二個建議完美運行。 –