簡體   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