ProgramZen 2022-06-12 15:16 采纳率: 100%
浏览 57
已结题

SpringBoot2.7.0 Gradle7.4.2 排除默认Logging 换 Log4j2 问题

问题遇到的现象和发生背景

我用的是SpringBoot2.7.0+Gradle7.4.2+Log4j2

问题相关代码,请勿粘贴截图

 implementation("org.springframework.boot", "spring-boot-starter") {
        // 排除 SpringBoot 自带的日志系统, 使用 Log4J2
        exclude("org.springframework.boot", "spring-boot-starter-logging")
    }
运行结果及报错内容
D:\SoftWare\Java\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:D:\SoftWare\idea2021.3.3\lib\idea_rt.jar=53990:D:\SoftWare\idea2021.3.3\bin -Dfile.encoding=UTF-8 -classpath D:\SoftWare\contract-plus\build\classes\kotlin\main;D:\SoftWare\contract-plus\build\resources\main;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-validation\2.7.0\1a7d12c3b10ec1c30ca3a6eb38d550f4a3876b31\spring-boot-starter-validation-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.7.0\7bf2381d030023970b5375c1090545e480467aa1\spring-boot-starter-web-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.7.0\49f204ec9672800932f8f7b344221251b1422da6\spring-boot-starter-aop-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.baomidou\mybatis-plus-boot-starter\3.5.1\4dc0a88a0df2ea31a2dc6cce038042583118e730\mybatis-plus-boot-starter-3.5.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.7.0\64fd3c21486dd20df9a62566599337dae2eb62cc\spring-boot-starter-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-log4j2\2.7.0\12aa77b31285912c03f01a8698640f67e5ba4b6b\spring-boot-starter-log4j2-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-undertow\2.7.0\33d02ad21bf932d03009cd709b184f8834ad365d\spring-boot-starter-undertow-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.baomidou\mybatis-plus-generator\3.5.2\77500b2ac117b553fcbf038be8337a6aa0a8a089\mybatis-plus-generator-3.5.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.alibaba\druid-spring-boot-starter\1.2.9\8f6c6ca8a8df0afe4000b8429dfc8bef3ee3e97a\druid-spring-boot-starter-1.2.9.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\mysql\mysql-connector-java\8.0.29\16bfffda393ac4fe56f0985f1f035b37d3fc48f\mysql-connector-java-8.0.29.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-devtools\2.7.0\2a45b04877bbfe9750e4d29f6a73f125e146513d\spring-boot-devtools-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.dataformat\jackson-dataformat-yaml\2.13.3\9363ded5441b1fee62d5be0604035690ca759a2a\jackson-dataformat-yaml-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.6.21\5dc3574d9b7bebfcb4ec6b10ada4aaa9e140bd0b\kotlin-reflect-1.6.21.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.6.21\eeb4d60d75e9ea9c11200d52974e522793b14fba\kotlin-stdlib-jdk8-1.6.21.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\cn.hutool\hutool-all\5.8.1\3b210a56543527e472d30837d93a008cc98c9c6c\hutool-all-5.8.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.google.guava\guava\31.1-jre\60458f877d055d0c9114d9e1a2efb737b4bc282c\guava-31.1-jre.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.63\b595f0bdae0392c8b3c8592fea10023956a3f619\tomcat-embed-el-9.0.63.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.2.3.Final\ea4545d1a97b27bada5f2e3f74c6172e641ecf39\hibernate-validator-6.2.3.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.7.0\f7120f4a6fd5dd2ca2128061e420e45ae2294943\spring-boot-starter-json-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.3.20\8ac1b72a1f5c41fdc2cb3340cd94f795af260301\spring-webmvc-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-web\5.3.20\3c2fe9363760d62d5b7c9f087bb4255e3377a0b2\spring-web-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.20\c82f17997ab18ecafa8d08ce34a7c7aa4a04ef9e\spring-aop-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.7\158f5c255cd3e4408e795b79f7c3fbae9b53b7ca\aspectjweaver-1.9.7.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.7.0\dd69f21efd63a2a16d631210b5656dc30348451b\spring-boot-starter-jdbc-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.7.0\483f9a66d0e8326583c5054038d0aa0a95045dc3\spring-boot-autoconfigure-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.baomidou\mybatis-plus\3.5.1\afb09f9fee588b3c2f099652e0c7c26e11679f03\mybatis-plus-3.5.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.7.0\df8bd106d6c6a6494b787b71d23cef6d2dc73703\spring-boot-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.20\4b88aa3c401ede3d6c8ac78ea0c646cf326ec24b\spring-core-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.30\8fde7fe2586328ac3c68db92045e1c8759125000\snakeyaml-1.30.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.7.0\5ff2a55d345ad824f39d55eaa32203865a92b30f\spring-boot-starter-logging-2.7.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-slf4j-impl\2.17.2\183f7c95fc981f3e97d008b363341343508848e\log4j-slf4j-impl-2.17.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-core\2.17.2\fa43ba4467f5300b16d1e0742934149bfc5ac564\log4j-core-2.17.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-jul\2.17.2\6a479ffc13d5f0ca3df8117ed57419fc5d06de7f\log4j-jul-2.17.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.36\ed46d81cef9c412a88caef405b58f93a678ff2ca\jul-to-slf4j-1.7.36.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\io.undertow\undertow-websockets-jsr\2.2.17.Final\340928906302abf674ec93f6d99682abb547a9f5\undertow-websockets-jsr-2.2.17.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\io.undertow\undertow-servlet\2.2.17.Final\d1dec6b9bdf8d1e9380d8003fbfa0b7d6785b292\undertow-servlet-2.2.17.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\io.undertow\undertow-core\2.2.17.Final\3a47f6d21357aeea1a834da290186f671a8427bb\undertow-core-2.2.17.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\jakarta.servlet\jakarta.servlet-api\4.0.4\b8a1142e04838fe54194049c6e7a18dae8f9b960\jakarta.servlet-api-4.0.4.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\jakarta.websocket\jakarta.websocket-api\1.1.2\69c2fdfb75081cc935bc9d6c5616d12b0b73815f\jakarta.websocket-api-1.1.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.alibaba\druid\1.2.9\1019c77634341b3b2dafe553a71c1874a7dce570\druid-1.2.9.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.36\6c62681a2f655b49963a5983b8b0950a6120ae14\slf4j-api-1.7.36.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.13.3\56deb9ea2c93a7a556b3afbedd616d342963464e\jackson-databind-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.13.3\a27014716e4421684416e5fa83d896ddb87002da\jackson-core-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.6.21\11ef67f1900634fd951bad28c53ec957fabbe5b8\kotlin-stdlib-1.6.21.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.6.21\568c1b78a8e17a4f35b31f0a74e2916095ed74c2\kotlin-stdlib-jdk7-1.6.21.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.google.guava\failureaccess\1.0.1\1dcf1de382a0bf95a3d8b0849546c88bac1292c9\failureaccess-1.0.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.google.guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\b421526c5f297295adef1c886e5246c39d4ac629\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.checkerframework\checker-qual\3.12.0\d5692f0526415fcc6de94bb5bfbd3afd9dd3b3e5\checker-qual-3.12.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.google.errorprone\error_prone_annotations\2.11.0\c5a0ace696d3f8b1c1d8cc036d8c03cc0cbe6b69\error_prone_annotations-2.11.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.google.j2objc\j2objc-annotations\1.3\ba035118bc8bac37d7eff77700720999acd9986d\j2objc-annotations-1.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\jakarta.validation\jakarta.validation-api\2.0.2\5eacc6522521f7eacb081f95cee1e231648461e7\jakarta.validation-api-2.0.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.4.3.Final\c4bd7e12a745c0e7f6cf98c45cdcdf482fd827ea\jboss-logging-3.4.3.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml\classmate\1.5.1\3fe0bed568c62df5e89f4f174c101eab25345b6c\classmate-1.5.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.13.3\d4884595d5aab5babdb00ddbd693b8fd36b5ec3c\jackson-datatype-jdk8-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.13.3\ad2f4c61aeb9e2a8bb5e4a3ed782cfddec52d972\jackson-datatype-jsr310-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.13.3\f71c4ecc1a403787c963f68bc619b78ce1d2687b\jackson-module-parameter-names-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.20\517a42165221ea944c8b794154c10b69c0128281\spring-context-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.20\ab88bd9e3a8307f5c0516c15d295c88ec318659\spring-beans-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.20\20e179f0dfabf0a46428f22c2150c9c4850fd15d\spring-expression-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.3.20\140414df1080754fcefe12921543c599e51dfbb2\spring-jdbc-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.zaxxer\HikariCP\4.0.3\107cbdf0db6780a065f895ae9d8fbf3bb0e1c21f\HikariCP-4.0.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.baomidou\mybatis-plus-extension\3.5.1\6825fe56fa1c2dad47b1aac1247c50e9c30a2be2\mybatis-plus-extension-3.5.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.20\35119231d09863699567ce579c21512ddcbc5407\spring-jcl-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.11\4741689214e9d1e8408b206506cbe76d1c6a7d60\logback-classic-1.2.11.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.17.2\17dd0fae2747d9a28c67bc9534108823d2376b46\log4j-to-slf4j-2.17.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.17.2\f42d6afa111b4dec5d2aea0fe2197240749a4ea6\log4j-api-2.17.2.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jboss.threads\jboss-threads\3.1.0.Final\9b260c0302f637a84a52d3d118214a3c59217615\jboss-threads-3.1.0.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jboss.xnio\xnio-api\3.8.6.Final\68052c0d04b051653b59110ddfd49fc8597243b1\xnio-api-3.8.6.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.13.3\7198b3aac15285a49e218e08441c5f70af00fc51\jackson-annotations-2.13.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.6.21\5e5b55c26dbc80372a920aef60eb774b714559b8\kotlin-stdlib-common-1.6.21.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.springframework\spring-tx\5.3.20\9a4ec2249dc3523ac70e0710a64288c14fc3ff78\spring-tx-5.3.20.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.baomidou\mybatis-plus-core\3.5.1\386d7179e842c9162853c7146dcf7d7148aaf470\mybatis-plus-core-3.5.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.mybatis\mybatis-spring\2.0.6\eae03712acdf041a3590b816460945d4bd2691bc\mybatis-spring-2.0.6.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.11\a01230df5ca5c34540cdaa3ad5efb012f1f1f792\logback-core-1.2.11.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.wildfly.client\wildfly-client-config\1.0.1.Final\2a803b23c40a0de0f03a90d1fd3755747bc05f4b\wildfly-client-config-1.0.1.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.wildfly.common\wildfly-common\1.5.4.Final\735ceee5616d5143bac1bc740e444697073c002f\wildfly-common-1.5.4.Final.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.baomidou\mybatis-plus-annotation\3.5.1\eaff62ce3f8294e4208215af3b1f7d9a25e0cb1e\mybatis-plus-annotation-3.5.1.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\com.github.jsqlparser\jsqlparser\4.3\db0878bb363ff3342aafd69847299b68083a0003\jsqlparser-4.3.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.mybatis\mybatis\3.5.9\991a4095dbb95d929dfe0a18a69692fd4c614e\mybatis-3.5.9.jar;D:\SoftWare\repository\caches\modules-2\files-2.1\org.jboss.xnio\xnio-nio\3.8.6.Final\5b13dd672834c8b16b1421b9b7f0a8ce9b9f4794\xnio-nio-3.8.6.Final.jar com.contract.plus.ContractPlusApplicationKt
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/SoftWare/repository/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.17.2/183f7c95fc981f3e97d008b363341343508848e/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/SoftWare/repository/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.11/4741689214e9d1e8408b206506cbe76d1c6a7d60/logback-classic-1.2.11.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.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.contract.plus.ContractPlusApplicationKt.main(ContractPlusApplication.kt:15)
Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j
    at org.apache.logging.slf4j.Log4jLoggerFactory.validateContext(Log4jLoggerFactory.java:60)
    at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:44)
    at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:33)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:53)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
    at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog(LogAdapter.java:130)
    at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:91)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
    at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:179)
    ... 1 more
我的解答思路和尝试过的方法

重新删了.gradle编译文件 重新更改gradle 版本 试图在 spring-boot-starter 和spring-boot-starter-mvc添加排除 清空过仓库重新编译都没用。

我想要达到的结果

外部库中移除 spring-boot-starter-logging 依赖

  • 写回答

1条回答 默认 最新

  • lwdbcy 2022-06-13 13:48
    关注

    题主可以试着查看下依赖树,是否存在其他依赖于 spring-boot-starter-logging

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 6月13日
  • 已采纳回答 6月13日
  • 创建了问题 6月12日

悬赏问题

  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)
  • ¥15 DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI[/untitled30_war_e
  • ¥15 使用deepspeed训练,发现想要训练的参数没有梯度
  • ¥15 寻找一块做为智能割草机的驱动板(标签-stm32|关键词-m3)
  • ¥15 信息管理系统的查找和排序
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),怎么用读取的电磁传感器信号表示小车所在的位置
  • ¥15 如何解决y_true和y_predict数据类型不匹配的问题(相关搜索:机器学习)
  • ¥15 PB中矩阵文本型数据的总计问题。
  • ¥15 MATLAB卫星二体模型仿真
  • ¥15 怎么让数码管亮的同时让led执行流水灯代码