一、jar中没有主清单属性
说明:基于maven的springboot项目打包的jar文件,执行java -jar xxx-0.0.1-SNAPSHOT.jar时报错,提示jar中没有主清单
- 原因1,pom.xml文件中并没有添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
- 原因2,上一步添加了pom.xml之后,重新打包jar文件,执行时仍然提示没有主清单属性,继续修改pom.xml,添加executions的配置
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<executions>
- 完整的build模块如下,增加到pom.xml中:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- clean之后在重新打包即可
参考:segmentfault.com/a/[11900000…]