Spring 引导和 Gradle 多模块项目,无法正确加载依赖项

Spring boot and Gradle multi-modules project, failed to load dependencies correctly

基本上我有一个 spring 引导项目构建 Gradle。 该项目有一个根项目,其中包含另外 4 个子模块。 根项目 settings.gradle 如下所示:

rootProject.name = 'proj'

include 'proj-app'
include 'proj-integration-tests'
include 'proj-model'
include 'proj-service'

应用程序模块包含 spring-boot-gradle-插件并公开一些 api。

我想做的是创建仅包含集成测试的 proj-integration-tests 子模块。问题从这里开始,因为我需要 proj-app 依赖项。

所以在 proj-integration-tests 我有 build.gradle 包含:

dependencies {
  testCompile('org.springframework.boot:spring-boot-starter-web')
  testCompile('org.springframework.boot:spring-boot-starter-test')
  testCompile project(':proj-app')
  testCompile project(':proj-model')
}

自集成测试以来我需要 proj-app 依赖项:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ProjApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

需要位于 proj-app 模块中的 Spring 启动应用程序启动(ProjApplication.class)。

我从 Gradle 得到的错误是:"cannot find symbol ProjApplication"。

为什么 Gradle 无法正确管理 proj-app 依赖项? 提前致谢 ;)

似乎 proj-app 依赖项是以 spring 启动方式构建的。这意味着获得的工件是一个可执行文件 spring boot far jar.This 这就是为什么 proj-integration-tests 在编译时无法从 proj-app 找到 类 的原因。
因此,为了维护可执行 jar,并将 proj-app 作为 proj-integration-tests 模块中的依赖项,我修改了 proj app 中的 build.gradle 以创建两个 jar:在 spring 开机时尚方式与标准版:

bootJar {
baseName = 'proj-app-boot'
enabled = true
}

jar {
baseName = 'proj-app'
enabled = true
}