我有多个具有不同 3rd 方依赖项的微服务,目前使用默认的 Spring Boot docker 层将所有依赖项复制到相同的依赖项层。但是我想将依赖项拆分为核心和依赖项层。核心层包含 spring-boot-starter-webflux
、spring-boot-starter-actuator
、spring-cloud-starter-sleuth
,其余的依赖项如 jpa、streams 等进入依赖项层。
bootJar {
enabled = true
archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
layered {
application {
intoLayer("spring-boot-loader") {
include "org/springframework/boot/loader/**"
}
intoLayer("application")
}
dependencies {
intoLayer("application") {
includeProjectDependencies()
}
intoLayer("snapshot-dependencies") {
include "*:*:*SNAPSHOT"
}
intoLayer("core") {
include "org.springframework.boot:spring-boot-starter-webflux:*"
include "org.springframework:spring-webflux:*"
include "org.springframework.boot:spring-boot-starter-actuator:*"
}
intoLayer("dependencies")
}
layerOrder = ["core", "dependencies", "spring-boot-loader", "snapshot-dependencies", "application"]
}
}
这里的问题是分层包含不会传递性地包含依赖项。例如,spring-webflux
不包括 reactor
、netty
。我需要手动提及依赖项。有没有办法只为 core
层传递依赖项,而不是为 application
或 snapshot
以及对 dependencies
的其余依赖项传递依赖项。