当我运行“mvn spring-boot:build-image”时,为什么会出现“构建器生命周期“creator”失败,状态代码为 51”

Joh*_*ith 16 java spring maven docker spring-boot

我正在学习 Docker,并且正在尝试创建当前 Spring 项目的映像。

我正在尝试运行mvn spring-boot:build-image为我的 Spring Boot 项目创建一个 docker 映像,但是当我执行它时出现此错误:

 Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.7.0:build-image (default-cli) on project dwh-webservices: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.7.0:build
-image failed: Builder lifecycle 'creator' failed with status code 51 
Run Code Online (Sandbox Code Playgroud)

我在网上没有找到类似的东西,所以我在这里问这个问题。

这是我的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>2.7.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.business</groupId>
    <artifactId>dwh-webservices</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>DWH_WebServices</name>
    <description>DWH_WebServices</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

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

        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.28</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.25.0-GA</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.2.2.jre8</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.0.1-jre</version>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Run Code Online (Sandbox Code Playgroud)

难道我做错了什么 ?我错过了什么吗?

小智 2

几天前我也遇到了同样的问题。

问题是我的公司正在重写 TSL 证书,所以我无法下载它:

Get "https://repo.spring.io/release/org/springframework/cloud/spring-cloud-bindings/1.10.0/spring-cloud-bindings-1.10.0.jar": x509: certificate signed by unknown authority
Run Code Online (Sandbox Code Playgroud)

我必须手动添加它。我遵循这个并且它起作用了。

希望能帮助到你。