我正在使用 Spring Boot 来部署应用程序
在我的 pom 中我有:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>package.MainBootApp</mainClass>
</configuration>
</execution>
</executions>
</plugin>
使用 mvn clean install -Pdev 进行的编译构建成功,但是当我尝试使用 java -jar 运行 jar 时,它无法启动,并且出现以下错误:
It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
我使用命令 mvn package spring-boot:repackage -Pdev 重新编译了 Jar
一切都好。
不知道用常用命令mvn clean install编译的时候行不通
有什么想法吗?
最佳答案
你能试试这个吗
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>package.MainBootApp</mainClass>
<layout>ZIP</layout>
</configuration>
</plugin>
</plugins>
关于java - 生成可执行的spring boot jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49178194/