我正在创建一个带有Spring的多模块项目,用于部署我的应用程序,并使用gradle作为我的构建工具。
现在,我正在为项目中的一些模块创建独立的部署。有些项目需要嵌入tomcat,有些则不需要。所有公共依赖项都放在一个公共项目上,所有其他模块都依赖于这个公共项目。
大多数其他部署模块都需要嵌入式tomcat应用程序服务器和其他web组件(由org.SpringFrawork.boot提供,名称:‘spring starter’),因此这已包含在公共项目的build.gradle中。
以下是公共项目的build.gradle:
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: springBootVersion
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: springBootVersion
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: springDataJpaVersion现在,将独立部署的其他模块之一不需要这个内置的tomcat和其他mvc jars,这些jars包括spring starter,而是需要来自公共项目的其他传递依赖项。因此,我想排除
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion我在build.gradle其他项目中这样做
dependencies {
compile project(':common') {
exclude group 'org.springframework.boot', module:'spring-boot-starter-web'
}
}但是,在构建时,它会抛出以下错误:
启动失败:生成文件'/Users/user1/Documents/repo/storm/build.gradle':30:期待'}',找到',‘@第30行,第44列。oup‘org.Spring frawork.boot’,模块:‘
改为:
dependencies {
compile project(':common'){
exclude group 'org.springframework.boot:spring-boot-starter-web'
}
}投掷:
无法为项目‘:parent’上的参数父-项目名称找到方法exclude()。
在这里,我如何排除传递依赖?
发布于 2015-09-28 07:57:46
您需要在compile上调用compile而不是在project上调用
dependencies {
compile(project(':common')) {
exclude group: 'org.springframework.boot', module:'spring-boot-starter-web'
}
}https://stackoverflow.com/questions/32818122
复制相似问题