首页 > 解决方案 > 具有传递依赖关系的 Spring Boot Docker 层

问题描述

我有多个具有不同 3rd 方依赖项的微服务,目前使用默认的 spring boot docker 层,它将所有依赖项复制到相同的依赖项层。但是,我想将依赖项拆分为核心和依赖项层。核心层包含spring-boot-starter-webflux,和其他依赖项spring-boot-starter-actuatorspring-cloud-starter-sleuth如 jpa、流等进入依赖项层。

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及物。我需要手动提及依赖项。有没有办法只包含对corelayer 的依赖关系,而不是对applicationorsnapshot和其余依赖关系的依赖关系dependencies

标签: javaspring-bootdockerspring-boot-maven-pluginspring-boot-gradle-plugin

解决方案


推荐阅读