maven jar包冲突小记

本地调试报错:

 

  1. SLF4J: Class path contains multiple SLF4J bindings.  
  2. SLF4J: Found binding in [jar:file:/E:/repository/org/slf4j/slf4j-nop/1.6.1/slf4j-nop-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]  
  3. SLF4J: Found binding in [jar:file:/E:/repository/org/slf4j/slf4j-log4j12/1.7.12/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]  
  4. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.  
  5. SLF4J: Actual binding is of type [org.slf4j.helpers.NOPLoggerFactory]  

分析过程(先后执行了):

        mvn dependency:list
        mvn dependency:tree -Dverbose -Dincludes=org.slf4j

执行后输出为:

 

  1. [INFO] +- b:c:jar:2.0.0-SNAPSHOT:compile  
  2. [INFO] |  +- org.slf4j:slf4j-api:jar:1.7.12:compile  
  3. [INFO] |  \- com.google.code:fqueue:jar:0.0.2-release:compile  
  4. [INFO] |     +- commons-lang:commons-lang:jar:2.5:compile  
  5. [INFO] |     +- commons-logging:commons-logging:jar:1.1.1:compile  
  6. [INFO] |     +- org.slf4j:slf4j-nop:jar:1.6.1:compile  
  7. [INFO] |     \- org.jboss.netty:netty:jar:3.2.4.Final:compile  

  1. [INFO] +- b:d:jar:2.0.0-SNAPSHOT:compile  
  2. [INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.7.12:runtime  
  3. [INFO] |  +- log4j:log4j:jar:1.2.16:compile  
  4. [INFO] |  \- commons-codec:commons-codec:jar:1.4:compile  


就是因为a包依赖了b.c和b.d,这两者中的slf4j-nop和slf4j-log4j12冲突了。

 

解决办法,通过在dependency中采用exclusions来选择性的排除依赖就ok了

 

  1.               <dependency>  
  2.     <groupId>b</groupId>  
  3.     <artifactId>c</artifactId>  
  4.     <version>2.0.0-SNAPSHOT</version>  
  5.       <exclusions>  
  6.         <exclusion>  <!-- declare the exclusion here -->  
  7.       <groupId>org.slf4j</groupId>  
  8.       <artifactId>slf4j-nop</artifactId>                
  9.         </exclusion>  
  10.       </exclusions>                 
  11. </dependency>  


转载于:https://www.cnblogs.com/gscq073240/articles/8644219.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值