Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';t使用mvn spring引导构建war文件的映像:构建映像_Java_Spring_Spring Boot_Docker_Maven - Fatal编程技术网

Java Can';t使用mvn spring引导构建war文件的映像:构建映像

Java Can';t使用mvn spring引导构建war文件的映像:构建映像,java,spring,spring-boot,docker,maven,Java,Spring,Spring Boot,Docker,Maven,我试图使用SpringBootBuildImage目标为我的项目构建一个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\

我试图使用SpringBootBuildImage目标为我的项目构建一个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>
4.0.0
org.springframework.boot
spring启动程序父级
2.3.3.2发布
com.pdr
演示
0.0.1-快照
战争
演示
1.8
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
假如
org.springframework.boot
弹簧起动试验
测试
org.junit.vintage
朱尼特老式发动机
org.springframework.boot
springbootmaven插件

插件似乎在搜索一个jar文件,我正在构建一个war文件。如何解决这个问题?

您可以尝试将包装从war更改为jar

<packaging>jar</packaging>
jar

当前版本的spring(2.3.5)不支持使用mvn spring boot:build image或gradle bootBuildImage生成war文件类型的映像

他们决定将此功能添加到2.5X版本中。下面的里程碑链接也有同样的细节