maven依赖包冲突如何处理 SLF4J: Class path contains multiple SLF4J bindings.

 

目录

报错信息

报错原因

具体解决办法

第一步、找到依赖

第二步、对依赖添加排除依赖

总结


报错信息

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/mavenJarOnline/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:/E:/mavenJarOnline/org/slf4j/slf4j-log4j12/1.7.22/slf4j-log4j12-1.7.22.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

报错原因

maven的依赖里面有多个slf4j-log4j12,后者不同版本的slf4j-log4j12,有时候并不是pom.xml里面有多个slf4j-log4j12依赖配置,而是其他依赖连默认依赖了slf4j-log4j12,比如spring-boot-starter-web 和spring-boot-starter-ws,

具体解决办法

晚上搜了一些方法,其中一个是找到所有依赖slf4j-log4j12的库,然后排除对slf4j-log4j12的依赖,

第一步、找到依赖

右击pom.xml,maven->show Dependencies... ,将会看到项目的依赖图,然后ctrl+f 直接输入slf4j-log(ctrl+f后没有输入框,直接敲键盘后才会出现输入框),看看哪些依赖了slf4j-log然后一个个排除掉,具体怎么排除看第二步

maven依赖包冲突如何处理 SLF4J: Class path contains multiple SLF4J bindings._第1张图片

第二步、对依赖添加排除依赖

直接上配置


	org.springframework.boot
	spring-boot-starter-web
     
	
		
			org.slf4j
			slf4j-log4j12
		
	

 


	org.springframework.boot
	spring-boot-starter-ws
	
		
		
			org.springframework.boot
			spring-boot-starter-logging
		
	

总结

通过对日志依赖的排除,就不会有包冲突了,同理其他包冲突也可以这样处理,有时候换一个编辑器或者不同版本maven有不同的结果,同事编译都不会有包冲突的问题 ,而我的开发环境就会有包冲突问题。

你可能感兴趣的:(开发)