Spring 渐变从弹簧中排除SLF4J
好的,下面的代码可以工作,但是看起来不太好。我有一个Spring Boot项目,我想排除SLF4J,因为我想改用Log4j2 有人知道如何改进代码吗Spring 渐变从弹簧中排除SLF4J,spring,logging,gradle,log4j,spring-boot,Spring,Logging,Gradle,Log4j,Spring Boot,好的,下面的代码可以工作,但是看起来不太好。我有一个Spring Boot项目,我想排除SLF4J,因为我想改用Log4j2 有人知道如何改进代码吗 dependencies { compile("org.springframework:spring-context") { exclude module: "spring-boot-starter-logging" exclude module: "logback-classic" } co
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")
}
接受你的答案,因为这个版本看起来比我的版本好很多,谢谢。运行时是否等于提供的运行时?否。这些是不同的配置<代码>运行时来自
java
插件,而提供的运行时
来自war
:。我不知道您的配置,所以我只是将providedRuntime
替换为runtime
,以使其工作。为什么jar文件仍然存在于gradle缓存中,而它没有显示在gradle依赖项中,因此当我启动项目时,它仍然显示绑定问题,即使gradle依赖项列表没有用于重新登录的引用。。。有什么想法吗??