170803、springboot jar包启动提示没有主清单属性

时间:2024-01-14 09:30:50

问题:SpringBoot打包成jar后运行提示没有主清单属性

解决: 补全maven中的bulid信息

170803、springboot jar包启动提示没有主清单属性

 <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

  

原因:

因为我使用spring-boot-dependencies这个BOM代替了spring-boot-starter-parent这个parent POM(详见13.2.2. Using Spring Boot without the parent POM

导致spring-boot-maven-plugin的配置项丢失,使得打包后的jar中的MANIFEST.MF文件缺少Main-Class。

PS:当打包类型为jar时,spring-boot-maven-plugin的打包过程与直接使用maven-jar-plugin完全不同。生成的jar目录结构也有很大不同