gradle中依賴provided未生效.md
阿新 • • 發佈:2018-12-12
gradle中依賴provided未生效
問題情景
在引入gradle依賴時:
dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2') provided group: 'org.projectlombok', name: 'lombok', version: '1.16.18' compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6' compile group: 'com.alibaba', name: 'druid', version: '1.1.11' compile group: 'com.alibaba', name: 'fastjson', version: '1.2.49' testCompile('org.springframework.boot:spring-boot-starter-test') }
引入provided
依賴時,不能引入jar包
解決方案
網上找到解決方案,在build.gradle
檔案中加入:
configurations {
provided
}
sourceSets.main.compileClasspath += configurations.provided
sourceSets.test.compileClasspath += configurations.provided
sourceSets.test.runtimeClasspath += configurations.provided
其他的類似,像providedCompile
等等
perfect!