springboot项目中gradle依赖排除踩坑小记

1.关于SpringBoot+Gradle排除依赖的问题

之前项目中是下边的引入核心依赖工程的
compile project(‘:core’)
但是不能直接加大括号,需要先将加小括号包裹project后再加大括号排除

compile (project(':core')){
    exclude group: 'org.apache.poi', module: 'poi-ooxml'
}

如果没起作用可以试一下全局排除:

configurations.all {
    exclude group: 'org.apache.poi', module: 'poi-ooxml'
}
2.我的项目代码
dependencies {
	compile(
	        'org.springframework.boot:spring-boot-devtools',
            'org.springframework.cloud:spring-cloud-starter-consul-discovery:1.3.1.RELEASE',
            'org.springframework.cloud:spring-cloud-starter-feign:1.3.1.RELEASE',
            'org.springframework.boot:spring-boot-starter-actuator:1.4.5.RELEASE',
            'org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.0',
            'org.springframework.boot:spring-boot-starter-data-mongodb',
            'mysql:mysql-connector-java:5.1.38',
            'net.sf.json-lib:json-lib:2.4:jdk15',
            'tk.mybatis:mapper-spring-boot-starter:2.1.5',
            'org.apache.poi:poi-ooxml:3.17'
	       )
    if(env == "prod"){
        compile(
                'org.springframework.cloud:spring-cloud-starter-sleuth:1.2.1.RELEASE',
                'org.springframework.cloud:spring-cloud-sleuth-zipkin-stream:1.2.1.RELEASE',
                'org.springframework.cloud:spring-cloud-starter-stream-rabbit:1.2.1.RELEASE',
                'org.springframework.cloud:spring-cloud-starter-hystrix:1.3.1.RELEASE',
                'org.springframework.cloud:spring-cloud-netflix-hystrix-stream:1.3.1.RELEASE'

        )
    }
    testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.2.RELEASE'
    testCompile group: 'junit', name: 'junit', version: '4.12'
//    compile project(":core")
    compile(project(':core')) {
        exclude group: 'org.apache.poi', module: 'poi-ooxml'
    }
}

希望对大家有帮助!欢迎交流学习!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值