繁体   English   中英

如何从gradle中排除jar

[英]How to exclude a jar from gradle

我尝试从gradle构建中排除一个jar但是如何为我的项目部分做这个我不清楚。下面是我必须排除geronimo-javamail_1.4_spec / 1.7.1 jar的依赖项,因为当我尝试时会出错发送邮件。请给出指导来解决这个问题。

    dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons':'commons-lang3':'3.5'){
                exclude module: 'geronimo'
    }
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

更新:排除不起作用

首先,这个陈述存在一个问题:

compile('org.apache.commons':'commons-lang3':'3.5')

如果要将冒号表示法用于依赖项,则必须将其全部放在一个String中,如下所示:

compile('org.apache.commons:commons-lang3:3.5')

此外,您应该使用完整的模块名称: module: 'geronimo-javamail_1.4_spec'

最后, geronimo-javamail_1.4_spec是此设置中多个依赖项的传递依赖项,因此您应该在必要时将其逐个排除,或者将其完全排除,如下所示:

configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

这应该在build.gradle文件中添加到与dependencies{}部分相同的级别,而不是在其中,因此最终代码如下所示:

configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile("org.springframework.boot:spring-boot-starter-web")  
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons:commons-lang3:3.5')
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM