具有可传递依赖项的 Spring Boot Docker 层

时间:2021-05-22 06:37:50

标签: java spring-boot docker spring-boot-maven-plugin spring-boot-gradle-plugin

我有多个具有不同 3rd 方依赖项的微服务,目前使用默认的 Spring Boot docker 层将所有依赖项复制到相同的依赖项层。但是我想将依赖项拆分为核心和依赖项层。核心层包含 spring-boot-starter-webfluxspring-boot-starter-actuatorspring-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 不包括 reactornetty。我需要手动提及依赖项。有没有办法只为 core 层传递依赖项,而不是为 applicationsnapshot 以及对 dependencies 的其余依赖项传递依赖项。

0 个答案:

没有答案