gpt4 book ai didi

spring - Gradle 从 Spring 中排除 SLF4J

转载 作者:行者123 更新时间:2023-12-04 18:05:47 26 4
gpt4 key购买 nike

好吧,下面的代码有效,但看起来不太好。我有一个 Spring Boot 项目,我想排除 SLF4J,因为我想改用 Log4j2。

有谁知道如何改进代码?

dependencies {
compile("org.springframework:spring-context") {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-data-mongodb") {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-log4j2")
providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper")
testCompile("junit:junit")
}

最佳答案

你可以例如尝试:

dependencies {
[
"org.springframework:spring-context",
"org.springframework.boot:spring-boot-starter-web",
"org.springframework.boot:spring-boot-starter-data-mongodb",
].each { dep ->
compile(dep) {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
}
compile("org.springframework.boot:spring-boot-starter-log4j2")
runtime("org.apache.tomcat.embed:tomcat-embed-jasper")
testCompile("junit:junit")
}

关于spring - Gradle 从 Spring 中排除 SLF4J,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28525927/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com