Gradle 从 Spring 中排除 SLF4J
Gradle exclude SLF4J from Spring
好吧,下面的代码可以工作,但看起来不太好。我有一个 Spring 启动项目,我想排除 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 启动项目,我想排除 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")
}