Springboot打包jar中没有主清单属性

如果出现Spring Boot打包jar中没有主清单属性

1.png

官方是这样描述的

https://docs.spring.io/spring-boot/docs/2.3.4.RELEASE/reference/html/getting-started.html#getting-started

1
2
3
  The spring-boot-starter-parent POM includes <executions> configuration to bind the repackage goal. 
If you do not use the parent POM, you need to declare this configuration yourself.
See the plugin documentation for details.

image.png

大概意思就是说:引入org.springframework.boot父级如果不引入父级您需要自己声明配置。

1
2
3
4
5
6
7
<!-- Inherit defaults from Spring Boot -->
<!-- 最好加入这个,否则打包容易出问题 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
</parent>

当然插件也是需要的

1
2
3
4
5
6
7
8
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

这些官方文档里面也有。