我尝试从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')
}
Run Code Online (Sandbox Code Playgroud)
更新:排除不起作用
首先,这个陈述存在一个问题:
compile('org.apache.commons':'commons-lang3':'3.5')
Run Code Online (Sandbox Code Playgroud)
如果要将冒号表示法用于依赖项,则必须将其全部放在一个String中,如下所示:
compile('org.apache.commons:commons-lang3:3.5')
Run Code Online (Sandbox Code Playgroud)
此外,您应该使用完整的模块名称:module: 'geronimo-javamail_1.4_spec'.
最后,geronimo-javamail_1.4_spec在此设置中是多个依赖项的传递依赖项,因此您应该在必要时将其逐个排除,或者将其完全排除,如下所示:
configurations {
all*.exclude module: 'geronimo-javamail_1.4_spec'
}
Run Code Online (Sandbox Code Playgroud)
这应该添加到您的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')
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13718 次 |
| 最近记录: |