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

问题描述

我有多个具有不同 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 的其余依赖项传递依赖项。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)