Gradle build命令构建基于SpringCloud项目,执行到某一个子项目时,提示程序包不存在
整个项目是基于 spring cloud 的
父项目的 build.gradle 配置:
group 'com.xxx.yyy'
version '0.1.0'
buildscript {
ext {
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
subprojects {
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'docker'
apply plugin: 'org.springframework.boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java.srcDir "src"
}
}
repositories {
mavenCentral()
}
configurations {
all*.exclude module: 'spring-boot-starter-logging'
all*.exclude module: 'logback-classic'
}
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.SR3'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile('org.springframework.boot:spring-boot-starter-test')
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml')
}
}
子项目的配置就比较简单了
子项目1:
group 'com.xxx.yyy'
version '0.1.0'
archivesBaseName = 'prj1'
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
// ...
}
子项目2:
group 'com.xxx.yyy'
version '0.1.0'
archivesBaseName = 'prj2'
dependencies {
compile project(":prj1")
}
在父项目目录下,执行 gradle build -x test
命令时
> Task :prj2:compileJava
ConsumerHelper.java:5: 错误: 程序包com.xxx.yyy.zzz不存在
请问这个是什么原因导致。。。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
把主项目中的 build.gradle 内容一行一行条这个位置做测试,改了下仓库,最后终于可以了。。。
顺便在某些 module 下加上了
父项目需要新建一个 setting.gradle ,具体配置如下:
我这样没有用