首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle从Spring中排除SLF4J

Gradle从Spring中排除SLF4J
EN

Stack Overflow用户
提问于 2015-02-15 20:14:12
回答 1查看 10.4K关注 0票数 7

好吧,下面的代码可以工作,但看起来不是很好。我有一个Spring Boot项目,我想排除SLF4J,因为我想使用Log4j2。

有人知道如何改进代码吗?

代码语言:javascript
复制
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")
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-15 21:02:22

例如,你可以尝试:

代码语言:javascript
复制
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")
}
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28525927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档