Spring分层Fat Jar和Gradle插件layertools jarmode [英] Spring Layered Fat Jar and Gradle Plugin layertools jarmode

查看:358
本文介绍了Spring分层Fat Jar和Gradle插件layertools jarmode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Boot 2.3.0具有分层的脂肪罐,这些脂肪罐已针对容器映像构建进行了优化.现在,Spring文档仅讨论Maven构建工具,而不讨论Gradle.

Spring boot 2.3.0 has the layered fat jars which are optimized for container image builds. Now, the Spring documentation discusses only Maven build tool, and not Gradle.

请问,我们需要对Gradle插件做些什么,以使其能够为春季启动构建分层jar"?

Please, what do we need to do to the Gradle plugin to allow it to build a "layered jar" for spring boot?

例如:如果使用Gradle Spring引导插件id("org.springframework.boot") version "2.3.0.RELEASE"提取的命令java -Djarmode=layertools -jar app.jar extract提取jar,则失败,并显示消息:Unsupported jarmode 'layertools'.基本上,如果jar是使用./gradlew bootJar构建的,则默认情况下似乎分层的jar不处于活动状态.

For example: if extracting a jar with the command java -Djarmode=layertools -jar app.jar extract which has been made with Gradle Spring boot plugin id("org.springframework.boot") version "2.3.0.RELEASE" it fails with message: Unsupported jarmode 'layertools'. Basically if the jar has been built with ./gradlew bootJar it seems layered jar is not active by default.

提取分层的jar应该会导致以下目录,然后将这些目录复制到另一个容器映像中以供执行,并且仅当较低的层已更改时,缓存系统才必须重新读取它们. -Djarmode=layertools标志提取的分层jar:

Extracting a layered jar should result in the following directories, and these are then copied into another container image for execution, and only if lower layers have changed does the caching system have to re-read them. Layered jar extracted with -Djarmode=layertools flag:

./dependencies/
./snapshot-dependencies/
./resources/
./application/

春季博客

The blog at spring Spring Blog 2.3.0.ML discusses Maven build tool and the configuration:

<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
    <layout>LAYERED_JAR</layout>
</configuration>

我们如何为Gradle插件启用相同的配置?

How do we enable the same configuration for Gradle plugin?

推荐答案

该文档适用于如何使用spring-boot-gradle-plugin激活用于春季启动应用程序的分层胖子.

The documentation is available for how to activate the layered fat jar for spring boot applications with the spring-boot-gradle-plugin.

用Gradle包装分层罐子.

build.gradle文件中:

// Groovy solution
bootJar {
    layered()
}


// Kotlin solution
tasks.getByName<BootJar>("bootJar") {
    layered()
}

希望这会有所帮助.

这篇关于Spring分层Fat Jar和Gradle插件layertools jarmode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆