我正在学习弹簧靴和船坞,所以我对此还是个新手. 我try 使用以下命令构建一个docker映像:./mvnw SpringBoot:Build-Image,但它在运行的创建者步骤中失败了. Docker台式机在Windows 11上运行. 我try 了SDK 17和21,结果相同.我在网上找不到一个有帮助的答案.下面是我的pom.xml.

谢谢你的帮助

 > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Image with name "docker.io/library/docker-demo:0.0.1-SNAPSHOT" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 26 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.6.6
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.4.4
[INFO]     [creator]     paketo-buildpacks/syft              1.41.1
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.8.3
[INFO]     [creator]     paketo-buildpacks/dist-zip          5.6.8
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.27.7
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.6.6
[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.4.4
[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              17                                                           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 20 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]     ERROR: failed to build: exit status 1
[INFO]     [creator]     unable to request
[INFO]     [creator]     Get "": unsupported protocol scheme ""
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  14.179 s
[INFO] Finished at: 2023-12-22T08:13:29+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.0:build-image (default-cli) on project docker-demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.2.0: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

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.2.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>fr.wcs</groupId>
    <artifactId>docker-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>docker-demo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>

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

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

</project>

推荐答案

你面临着和这SO question个人一样的问题

在构建日志(log)中,您可以看到它试图加载JDK 20

Using Java version 20 extracted from MANIFEST.MF

You can define the good java-version using this documentation
It should looks like the following :

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <image>
            <env>
                <BP_JVM_VERSION>17</BP_JVM_VERSION> <!-- or use your ${java.version} property -->
            </env>
        </image>
    </configuration>
</plugin>

Java相关问答推荐

为什么接口中的主函数而不是类中的主函数在Java 17中编译和运行没有问题?

为什么在枚举中分支预测比函数调用快?

Hibernate 6支持Joda DateTime吗?

通过合并Akka Streams中的多个慢源保持订购

DTO到实体,反之亦然,控制器和服务之间的哪一层应该处理转换?

为什么一个Test的instance?& gt;在构造函数中接受非空对象?

在Java中如何从Executors.newFixedThreadPool(MAX_THREAD_COUNT())迁移到虚拟线程

如何在Application.yaml中连接字符串?

Log4j与jdk21兼容吗?

当构造函数创建一个新实例时,Java为什么需要&new";

将ByteBuffer异步写入InputStream或Channel或类似对象

Java组件项目中的JavaFX对话框国际化

具有多个模式的DateTimeForMatter的LocalDate.parse失败

如果执行@BeForeEach#repository.save(),则测试中的UnitTest最终UUID会发生更改

如何在Java中使用正则表达式拆分字符串

在ECLIPSE上的M1 Pro上运行JavaFX的问题

ReturnedRect在升级后反转

简化每个元素本身都是 map 列表的列表

类型安全:从 JSONArray 到 ArrayList> 的未经判断的转换

在java中使用SevenZip.openArchive方法后无法删除文件