java 生成器生命周期“creator”失败,状态代码为51

k4emjkb1  于 2023-03-06  发布在  Java
关注(0)|答案(1)|浏览(365)

在我的springboot应用程序中,当我试图通过这个命令构建我的docker映像时,我发出了一个问题

mvn spring-boot:build-image -DskipTests

我看到结果是构建失败:

[INFO] Scanning for projects...
[INFO] 
[INFO] ------< com.in28minutes.microservices:currency-exchange-service >-------
[INFO] Building currency-exchange-service-docker 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:3.0.2:build-image (default-cli) > package @ currency-exchange-service >>>
[INFO] 
[INFO] --- maven-resources-plugin:3.3.0:resources (default-resources) @ currency-exchange-service ---
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ currency-exchange-service ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.3.0:testResources (default-testResources) @ currency-exchange-service ---
[INFO] skip non existing resourceDirectory C:\Users\vavil\Desktop\spring-microservices\spring-microservices-v3-main\04.docker\currency-exchange-service\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ currency-exchange-service ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ currency-exchange-service ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ currency-exchange-service ---
[INFO] 
[INFO] --- spring-boot-maven-plugin:3.0.2:repackage (repackage) @ currency-exchange-service ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] <<< spring-boot-maven-plugin:3.0.2:build-image (default-cli) < package @ currency-exchange-service <<<
[INFO]
[INFO] 
[INFO] --- spring-boot-maven-plugin:3.0.2:build-image (default-cli) @ currency-exchange-service ---
[INFO] Building image 'docker.io/in28min/mmv3-currency-exchange-service:0.0.1-SNAPSHOT'
[INFO]
[INFO]  > Executing lifecycle version v0.16.0
[INFO]  > Using build cache volume 'pack-cache-3c5bb71319ef.build'
[INFO]
[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Previous image with name "docker.io/in28min/mmv3-currency-exchange-service:0.0.1-SNAPSHOT" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 24 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.5.1
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 9.10.3
[INFO]     [creator]     paketo-buildpacks/syft              1.24.2
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.6.0
[INFO]     [creator]     paketo-buildpacks/dist-zip          5.5.0
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.22.1
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.5.1
[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 9.10.3
[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              11                                                           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 18 extracted from MANIFEST.MF
[INFO]     [creator]       No valid JRE available, providing matching JDK instead. Using a JDK at runtime has security implications.
[INFO]     [creator]        : Contributing to layer
[INFO]     [creator]       Warning: Dependency has no SHA256. Skipping cache.
[INFO]     [creator]         Downloading from
[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]     ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.631 s
[INFO] Finished at: 2023-03-02T10:31:09+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.2:build-image (default-cli) on project currency-exchange-service: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3
.0.2:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

我试着更改我的pomiderxml和一些版本,以检查是否存在版本兼容性问题,但我仍然面临同样的问题。
下面是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.in28minutes.microservices</groupId>
    <artifactId>currency-exchange-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>currency-exchange-service-docker</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>17</java.version>
        <spring-cloud.version>2022.0.0</spring-cloud.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <!--        <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-starter-config</artifactId>
                </dependency>
         -->
        <!-- Spring Boot 3+ Tracing -->

        <!-- Micrometer > Brave/OpenTelemetry > Zipkin -->

        <!-- Micrometer - Vendor-neutral application observability facade. Instrument your JVM-based application code without vendor lock-in.  Observation (Metrics & Logs) + Tracing.-->

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-observation</artifactId>
        </dependency>

        <!-- Brave as Bridge -->

        <!--
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-tracing-bridge-brave</artifactId>
        </dependency>

        <dependency>
            <groupId>io.zipkin.reporter2</groupId
            <artifactId>zipkin-reporter-brave</artifactId>
        </dependency>
        -->

        <!-- Open Telemetry as Bridge -->
        <!-- Open Telemetry - Simplified Observability (metrics, logs, and traces) -->

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-tracing-bridge-otel</artifactId>
        </dependency>

        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-zipkin</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-spring-boot2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <name>in28min/mmv3-${project.artifactId}:${project.version}</name>
                    </image>
                    <pullPolicy>IF_NOT_PRESENT</pullPolicy>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

</project>

我还尝试更改此版本:

<groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.2</version>

致:

<version>2.7.4</version>

但是我在一些类中得到错误,因为我使用了导入,例如:

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
lf3rwulv

lf3rwulv1#

尝试下载JRE或JDK以在生成的映像中使用时,映像构建失败。输出显示Using Java version 18 extracted from MANIFEST.MF,但输出(paketo-buildpacks/bellsoft-liberica 9.10.3)中显示的BellSoft Liberica的Paketo Buildpack不支持Java 18(有关它支持的版本,请参阅release notes)。
Using Java version 18 extracted from MANIFEST.MF输出表明Sping Boot 生成的jar文件中的META-INF/MANIFEST.MF文件包含Build-Jdk-Spec: 18行。这不应该是这种情况,因为上面的pom.xml<java.version>17</java.version>,所以看起来不太对劲。
您应该确保jar清单中的Build-Jdk-Spec条目与Bellsoft Liberica的Paketo Buildpack支持的JRE条目之一(即1719)匹配。Maven应该自动设置此条目,除非构建中的其他内容正在修改jar清单。
您还可以选择显式配置构建包以使用所需的JRE版本,如Sping Boot 文档中所示。

相关问题