2017-03-28 4 views
0

私のアプリケーションでは、2つのログファイル(org/slf4j/impl/StaticLoggerBinder.class)のバインディングがあります。以下を参照してください:クラスパスからログバックを削除できません

 <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-thymeleaf</artifactId> 
     </dependency> 

は、しかし、私が持っている:私はまた、関連する依存関係から除外しようとしてい

 <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> 

:私はクラスパスから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] 

失敗しました。どのようにログバックを削除できますか?事前に

[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 

ありがとう:

は、ここで依存関係ツリーの関連部分です。

答えて

2

あなたはgroupIdartifactIdが間違った方法を持っています。除外は次のようになります。

<exclusion> 
    <groupId>ch.qos.logback</groupId> 
    <artifactId>logback-classic</artifactId> 
</exclusion> 

だけではなくlogback-classicを除く、あなたの代わりにspring-boot-starter-loggingを除外することもできます。

<exclusion> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-logging</artifactId> 
</exclusion> 

は、これはまた、スターターその様々な他のLogback-とSLF4J関連の依存関係を保証します依存していない。

+0

ありがとう@Andy Wilkinson!私がch.qos.logbackを試したときに、次のようなエラーが出ました:スレッド "main"の例外java.lang.StackOverflowError \t at org.slf4j.impl.Log4jLoggerFactory.getLogger .... 2番目の提案は完全に機能しました。 –

関連する問題