maven jar包冲突小记

本地调试报错:

SLF4J: Class path contains multiple SLF4J bindings.
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]
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]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.helpers.NOPLoggerFactory]

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

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

执行后输出为:

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

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


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


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

                <dependency>
			<groupId>b</groupId>
			<artifactId>c</artifactId>
			<version>2.0.0-SNAPSHOT</version>
		      <exclusions>
		        <exclusion>  <!-- declare the exclusion here -->
			  <groupId>org.slf4j</groupId>
			  <artifactId>slf4j-nop</artifactId>	          
		        </exclusion>
		      </exclusions>				
		</dependency>


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值