使用maven构建项目时,使用了slf4j+logback,并没有主动添加log4j依赖,但是仍然报下面错误:
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
at org.slf4j.impl.Log4jLoggerFactory.
也就是说log4j-over-slf4j.jar和slf4j-log4j12.jar被其他依赖自动导入进来了,因此进行排查。
在pom.xml文件中,右键-maven-show dependencies
然后打开依赖的图, 看到依赖关系之后,ctrl+f 直接搜索log4j相关依赖:
选择需要排除的依赖然后右键-Exclude即可。
最终在pom.xml文件里自动排除我们在界面exclude的依赖。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有