通过 maven 插件使用 paketobuildpacks 构建 Spring Boot 3.1.5 映像不起作用

Building Spring Boot 3.1.5 image using paketobuildpacks via maven plugin is not working

提问人:dbaltor 提问时间:10/28/2023 更新时间:10/28/2023 访问量:440

问:

我正在使用 Spring Boot , Java 和 maven 。我在运行时出现以下错误3.1.5213.9.5mvn spring-boot:build-image

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder@sha256:17ea21162ba8c7717d3ead3ee3836a368aced7f02f2e59658e52029bd6d149e7'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO]  > Pulled run image 'paketobuildpacks/run@sha256:1af9935d8987fd52b2266d288200c9482d1dd5529860bbf5bc2d248de1cb1a38'
[INFO]  > Executing lifecycle version v0.16.5
[INFO]  > Using build cache volume 'pack-cache-8847f704ad41.build'
[INFO] 
[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Image with name "docker.io/library/elevate-insights:0.0.1-SNAPSHOT" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 26 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.6.3
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.2.6
[INFO]     [creator]     paketo-buildpacks/syft              1.32.1
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.7.4
[INFO]     [creator]     paketo-buildpacks/dist-zip          5.6.4
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.26.1
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.6.3
[INFO]     [creator]       https://github.com/paketo-buildpacks/ca-certificates
[INFO]     [creator]       Launch Helper: Contributing to layer
[INFO]     [creator]         Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for BellSoft Liberica 10.2.6
[INFO]     [creator]       https://github.com/paketo-buildpacks/bellsoft-liberica
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
[INFO]     [creator]         $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
[INFO]     [creator]         $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
[INFO]     [creator]         $BP_JVM_VERSION              21                                                           the Java version
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
[INFO]     [creator]         $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
[INFO]     [creator]         $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
[INFO]     [creator]         $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
[INFO]     [creator]         $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
[INFO]     [creator]         $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
[INFO]     [creator]         $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
[INFO]     [creator]         $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
[INFO]     [creator]         $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
[INFO]     [creator]         $BPL_JMX_PORT                5000                                                         configure the JMX port
[INFO]     [creator]         $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
[INFO]     [creator]         $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
[INFO]     [creator]         $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
[INFO]     [creator]         $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
[INFO]     [creator]         Using Java version 21 from BP_JVM_VERSION
[INFO]     [creator]       No valid JRE available, providing matching JDK instead. Using a JDK at runtime has security implications.
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to get dependency 
[INFO]     [creator]     unable to download 
[INFO]     [creator]     unable to request 
[INFO]     [creator]     Get "": unsupported protocol scheme ""
[INFO]     [creator]        : Contributing to layer
[INFO]     [creator]       Warning: Dependency has no SHA256. Skipping cache.
[INFO]     [creator]         Downloading from 
[INFO]     [creator]     ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.278 s
[INFO] Finished at: 2023-10-27T18:49:36+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:build-image (default-cli) on project elevate-insights: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]

这是我的pom文件的片段:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

// omitted 

    <properties>
        <java.version>21</java.version>
    </properties>

// omitted

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                    <image>
                        <env>
                            <BP_JVM_VERSION>21</BP_JVM_VERSION>
                        </env>
                    </image>
                </configuration>
            </plugin>

注意:尝试使用 Java 17 也没有任何喜悦

spring-bootspring-boot-maven-plugin 构建包 java-21

评论


答:

7赞 Daniel Mikusa 10/28/2023 #1

您使用的是旧构建器。

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%

该构建器适用于 Ubuntu 18.04 Bionic。Ubuntu已经不再支持它,所以它也不再支持Paketo项目。builder:base

您需要使用最新的构建器,它具有具有 Java 21 的最新构建包。paketobuildpacks/builder-jammy-base

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <builder>paketobuildpacks/builder-jammy-base:latest</builder>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

如果您使用的是 Spring Boot 3.1 或更早版本,则需要进行此手动更改。从 Spring Boot 3.2 开始,它将默认使用 Jammy 构建器。

Spring 团队的更新:

2023 年 11 月 23 日更新:Paketo 团队宣布,他们将在 2024 年 1 月取消对 Paketo 仿生构建器的访问。为了使这种过渡更容易,Spring Boot 在版本 2.7.18、3.0.13 和 3.1.6 的维护版本中将默认构建器更改为 Paketo Jammy 构建器。

原始公告请看这里: https://spring.io/blog/2023/09/22/paketo-buildpacks-bionic-end-of-support

评论

0赞 dbaltor 10/29/2023
嘿丹尼尔,你是传奇!它一如既往地工作!很高兴再次收到您的来信。谢谢你的帮助。