以Spring Boot的Web起步依赖为例,传递依赖了Jackson JSON库,有时候可能不需要用到该库,可以将传递依赖排除掉。
compile("org.springframework.boot:spring-boot-starter-web"){
exclude group: 'com.fasterxml.jackson.core'
}'
如果某个依赖版本比Spring Boot的Web起步依赖引入的要新,可以在build.gradle文件里指明所要版本
compile("com.fasterxl.jackson.core:jackson-databind:2.4.3")
但是,如果需要使用较老版本的库,则不得不把老版本的依赖加入构建,并排除掉web起步依赖传递依赖的版本
compile("org.springframework.boot:spring-boot-starter-web"){
exclude group:'com.fasterxml.jackson.core'
}
compile ("com.fasterxml.jackson.core:jackson-databind:2.3.1")