2017-07-07 122 views
0

我有一個slf4j依賴關係問題。無法刪除slf4j依賴關係

在pom.xml中,我聲明這一點:

 <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.7.12</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-api</artifactId>    
      </exclusion> 
     </exclusions>  
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.12</version> 
    </dependency> 

但我遇到此錯誤消息:

SLF4J: Class path contains multiple SLF4J bindings. 
    SLF4J: Found binding in    
    [jar:file:/C:/Users/r.rossi/.m2/repository/org/slf4j/slf4j- 
    nop/1.5.3/slf4j-nop-1.5.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
    SLF4J: Found binding in 
    [jar:file:/C:/Users/r.rossi/.m2/repository/org/slf4j/slf4j- 
    jdk14/1.5.6/slf4j-jdk14- 
    1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
    SLF4J: Found binding in 
    [jar:file:/C:/Users/r.rossi/.m2/repository/org/slf4j/slf4j- 
    log4j12/1.7.12/slf4j-log4j12- 
    1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an 
    explanation. 
    SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding. 
    SLF4J: Your binding is version 1.5.5 or earlier. 
    SLF4J: Upgrade your binding to version 1.6.x. 

在這些directorties和Maven依賴我有1.5版本,但我沒有POM.xml文件(如你所見),所以我不知道如何刪除它們。如果我刪除目錄,它可以工作,但下一個項目再次下載1.5版本的項目。我怎樣才能刪除那些該死的1.5版本?

+0

在執行和清理存儲庫緩存之前,您是否嘗試過清理構建? – Nico

回答

2

由於錯誤堆棧建議檢查鏈接Multiple Binding
此外,請檢查Dependency Tree以檢查哪個外部依賴項試圖包含(1.5.5或更早版本)。 基本上,你的排斥代碼

<exclusions> 
    <exclusion> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId>    
    </exclusion> 
</exclusions> 

應該插入的依賴性依賴於早期版本的1.5.5裏面。