![](/img/trans.png)
[英]I failed to use `mvn spring-boot:build-image` and remote docker daemon on win10
[英]Can't build image of war file using mvn spring-boot:build-image
我正在尝试使用 Spring Boot build-image 目标为我的项目构建 Docker 镜像(打包到 war 文件,而不是 jar 文件),但出现此错误
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.3.RELEASE:build-image failed: Source must refer to an existing file, got E:\my_project\Java\Workspace\demo\target\demo-0.0.1-SNAPSHOT.jar
这是我用来构建图像的命令
mvn spring-boot:build-image -Dspring-boot.build-image.imageName=projectio/demo
这是我的 pom 文件
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.pdr</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
该插件似乎在搜索 jar 文件,而我正在构建一个 war 文件,我该如何解决这个问题?
当前版本的 spring(2.3.5) 不支持使用 mvn spring-boot:build-image 或 gradle bootBuildImage 构建 war 文件类型的镜像。
他们决定将此功能添加到 2.5X 版本中。 下面的里程碑链接有关于相同的详细信息。
https://github.com/spring-projects/spring-boot/issues/22821
https://github.com/spring-projects/spring-boot/milestone/185
您可以尝试将包装从战争更改为罐子
<packaging>jar</packaging>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.