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

使用spring-boot:build-image构建镜像失败求助

Spring Boot Buildpack构建镜像失败:Get "" : unsupported protocol scheme "" 问题排查与解决

这个错误说明Buildpack在发起网络请求时目标URL为空,大概率是镜像仓库配置、代理设置异常,或是Java 19与Buildpack的兼容性配置问题,以下是具体排查和解决步骤:

排查镜像仓库配置

  • 检查Maven settings.xml 中的镜像配置,确保<mirrors>下的<url>字段没有空值,私有仓库地址格式正确(需带http://或https://前缀)。
  • 确认系统环境变量DOCKER_REGISTRY是否被误设为空,若有自定义仓库地址,需正确配置完整URL。

检查代理配置

  • 若网络需代理,验证HTTP_PROXY、HTTPS_PROXY、NO_PROXY环境变量是否配置完整,避免空值。可在Spring Boot插件中显式指定代理:
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <image>
          <env>
            <HTTP_PROXY>http://your-proxy-address:port</HTTP_PROXY>
            <HTTPS_PROXY>http://your-proxy-address:port</HTTPS_PROXY>
            <NO_PROXY>localhost,127.0.0.1,internal-domain</NO_PROXY>
          </env>
        </image>
      </configuration>
    </plugin>
    

确保Java 19与Buildpack兼容

  • 显式指定支持Java 19的Buildpack builder镜像,避免默认镜像不兼容:
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <image>
          <builder>paketobuildpacks/builder-jammy-base:latest</builder>
          <buildpacks>
            <buildpack>paketobuildpacks/java</buildpack>
          </buildpacks>
        </image>
      </configuration>
    </plugin>
    
  • 确认pom.xml中Java版本配置无误:
    <properties>
      <java.version>19</java.version>
      <maven.compiler.source>${java.version}</maven.compiler.source>
      <maven.compiler.target>${java.version}</maven.compiler.target>
    </properties>
    

清理缓存后重试

Buildpack缓存损坏可能导致异常,执行以下命令清理缓存后重新构建:

mvn spring-boot:build-image -Dspring-boot.build-image.clean-cache

定位日志细节

仔细查看完整构建日志,找到错误出现前的操作步骤,确认是拉取基础镜像、Java运行时还是项目依赖时触发的空URL请求,针对性修复对应配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 17:37:05