Well, the following code works but it does not really look good. I have a Spring Boot project and I want to exclude SLF4J because I would like to use Log4j2 instead.
Does anyone know how to improve the code?
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")
}
You can e.g. try:
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")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With