Sping Boot & Docker:无法执行goal org.springframework, Boot :spring- Boot -maven-plugin:3.2.0:build-image

guykilcj  于 2024-01-06  发布在  Spring
关注(0)|答案(1)|浏览(169)

我正在学习spring-boot和docker,所以我是新手。我尝试使用以下命令构建docker镜像:./mvnw spring-boot:build-image,但它失败了Running creator步骤。Docker桌面在Windows 11上运行。我尝试了SDK 17和21,结果相同。我在互联网上没有找到帮助的答案。下面是我的pom.xml。
谢谢你的帮助

  1. > Running creator
  2. [INFO] [creator] ===> ANALYZING
  3. [INFO] [creator] Image with name "docker.io/library/docker-demo:0.0.1-SNAPSHOT" not found
  4. [INFO] [creator] ===> DETECTING
  5. [INFO] [creator] 6 of 26 buildpacks participating
  6. [INFO] [creator] paketo-buildpacks/ca-certificates 3.6.6
  7. [INFO] [creator] paketo-buildpacks/bellsoft-liberica 10.4.4
  8. [INFO] [creator] paketo-buildpacks/syft 1.41.1
  9. [INFO] [creator] paketo-buildpacks/executable-jar 6.8.3
  10. [INFO] [creator] paketo-buildpacks/dist-zip 5.6.8
  11. [INFO] [creator] paketo-buildpacks/spring-boot 5.27.7
  12. [INFO] [creator] ===> RESTORING
  13. [INFO] [creator] ===> BUILDING
  14. [INFO] [creator]
  15. [INFO] [creator] Paketo Buildpack for CA Certificates 3.6.6
  16. [INFO] [creator] https://github.com/paketo-buildpacks/ca-certificates
  17. [INFO] [creator] Launch Helper: Contributing to layer
  18. [INFO] [creator] Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
  19. [INFO] [creator]
  20. [INFO] [creator] Paketo Buildpack for BellSoft Liberica 10.4.4
  21. [INFO] [creator] https://github.com/paketo-buildpacks/bellsoft-liberica
  22. [INFO] [creator] Build Configuration:
  23. [INFO] [creator] $BP_JVM_JLINK_ARGS --no-man-pages --no-header-files --strip-debug --compress=1 configure custom link arguments (--output must be omitted)
  24. [INFO] [creator] $BP_JVM_JLINK_ENABLED false enables running jlink tool to generate custom JRE
  25. [INFO] [creator] $BP_JVM_TYPE JRE the JVM type - JDK or JRE
  26. [INFO] [creator] $BP_JVM_VERSION 17 the Java version
  27. [INFO] [creator] Launch Configuration:
  28. [INFO] [creator] $BPL_DEBUG_ENABLED false enables Java remote debugging support
  29. [INFO] [creator] $BPL_DEBUG_PORT 8000 configure the remote debugging port
  30. [INFO] [creator] $BPL_DEBUG_SUSPEND false configure whether to suspend execution until a debugger has attached
  31. [INFO] [creator] $BPL_HEAP_DUMP_PATH write heap dumps on error to this path
  32. [INFO] [creator] $BPL_JAVA_NMT_ENABLED true enables Java Native Memory Tracking (NMT)
  33. [INFO] [creator] $BPL_JAVA_NMT_LEVEL summary configure level of NMT, summary or detail
  34. [INFO] [creator] $BPL_JFR_ARGS configure custom Java Flight Recording (JFR) arguments
  35. [INFO] [creator] $BPL_JFR_ENABLED false enables Java Flight Recording (JFR)
  36. [INFO] [creator] $BPL_JMX_ENABLED false enables Java Management Extensions (JMX)
  37. [INFO] [creator] $BPL_JMX_PORT 5000 configure the JMX port
  38. [INFO] [creator] $BPL_JVM_HEAD_ROOM 0 the headroom in memory calculation
  39. [INFO] [creator] $BPL_JVM_LOADED_CLASS_COUNT 35% of classes the number of loaded classes in memory calculation
  40. [INFO] [creator] $BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation
  41. [INFO] [creator] $JAVA_TOOL_OPTIONS the JVM launch flags
  42. [INFO] [creator] Using Java version 20 extracted from MANIFEST.MF
  43. [INFO] [creator] No valid JRE available, providing matching JDK instead. Using a JDK at runtime has security implications.
  44. [INFO] [creator] : Contributing to layer
  45. [INFO] [creator] Warning: Dependency has no SHA256. Skipping cache.
  46. [INFO] [creator] Downloading from
  47. [INFO] [creator] unable to invoke layer creator
  48. [INFO] [creator] unable to get dependency
  49. [INFO] [creator] unable to download
  50. [INFO] [creator] ERROR: failed to build: exit status 1
  51. [INFO] [creator] unable to request
  52. [INFO] [creator] Get "": unsupported protocol scheme ""
  53. [INFO] ------------------------------------------------------------------------
  54. [INFO] BUILD FAILURE
  55. [INFO] ------------------------------------------------------------------------
  56. [INFO] Total time: 14.179 s
  57. [INFO] Finished at: 2023-12-22T08:13:29+01:00
  58. [INFO] ------------------------------------------------------------------------
  59. [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]
  60. [ERROR]
  61. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  62. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  63. [ERROR]
  64. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  65. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

字符串
pom.xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>3.2.0</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>fr.wcs</groupId>
  12. <artifactId>docker-demo</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>docker-demo</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>17</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-data-jpa</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-web</artifactId>
  27. </dependency>
  28. <dependency>
  29. <groupId>com.h2database</groupId>
  30. <artifactId>h2</artifactId>
  31. <scope>test</scope>
  32. </dependency>
  33. <dependency>
  34. <groupId>org.postgresql</groupId>
  35. <artifactId>postgresql</artifactId>
  36. <scope>runtime</scope>
  37. </dependency>
  38. <dependency>
  39. <groupId>org.springframework.boot</groupId>
  40. <artifactId>spring-boot-starter-test</artifactId>
  41. <scope>test</scope>
  42. </dependency>
  43. </dependencies>
  44. <build>
  45. <plugins>
  46. <plugin>
  47. <groupId>org.springframework.boot</groupId>
  48. <artifactId>spring-boot-maven-plugin</artifactId>
  49. </plugin>
  50. </plugins>
  51. </build>
  52. </project>

mlnl4t2r

mlnl4t2r1#

您面临的问题与此SO question相同
在构建日志中,您可以看到它尝试加载JDK 20

  1. Using Java version 20 extracted from MANIFEST.MF

字符串
您可以使用此文档定义好的Java版本
它应该如下所示:

  1. <plugin>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-maven-plugin</artifactId>
  4. <configuration>
  5. <image>
  6. <env>
  7. <BP_JVM_VERSION>17</BP_JVM_VERSION> <!-- or use your ${java.version} property -->
  8. </env>
  9. </image>
  10. </configuration>
  11. </plugin>

展开查看全部

相关问题