You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot Maven Plugin的build-image命令执行失败求助

Spring Boot构建Docker镜像失败:"unsupported protocol scheme """问题排查

问题情况

  • 项目:从start.spring.io创建的Spring Boot 3.0.1、Java 17演示项目
  • 环境:Mac系统,本地使用OpenJDK 18.0.2
  • 执行命令:mvn spring-boot:build-image -Dspring-boot.build-image.imageName=testtesttest
  • 错误表现:构建失败,提示无法获取依赖、下载路径为空,核心错误Get "": unsupported protocol scheme ""

完整错误日志

[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:  14.756 s
[INFO] Finished at: 2023-01-02T15:18:19+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:build-image (default-cli) on project demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.0.1: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

解决方案

1. 统一项目与本地JDK版本

项目指定Java 17,但本地运行环境为JDK 18,版本不匹配会导致依赖下载逻辑异常:

  • 安装OpenJDK 17并切换为默认JDK(可通过jenv工具或export JAVA_HOME环境变量配置)
  • 在项目pom.xml中明确锁定JDK版本:
<properties>
    <java.version>17</java.version>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
</properties>

2. 修复Maven镜像配置

空路径下载通常是Maven的settings.xml中镜像地址配置错误(为空或缺失协议):

  • 打开~/.m2/settings.xml(无文件则新建)
  • 添加或修复镜像配置,示例:
<mirrors>
    <mirror>
        <id>aliyun-public</id>
        <mirrorOf>central</mirrorOf>
        <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
</mirrors>

3. 清理Maven缓存并重新构建

缓存损坏也可能导致依赖获取异常:

  • 执行清理命令:mvn clean install -U
  • 重新运行镜像构建命令:mvn spring-boot:build-image -Dspring-boot.build-image.imageName=testtesttest

4. 确认Spring Boot插件版本一致性

确保spring-boot-maven-plugin版本与项目Spring Boot版本完全一致:

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

内容的提问来源于stack exchange,提问作者Vinay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 08:55:12