執行Jar包報錯:no main manifest attribute以及spring-boot-maven-plugin報紅問題
阿新 • • 發佈:2021-04-05
問題描述:
在linux上部署jar包時報錯no main manifest attribute
解決
第一次對專案打包的時候,jar檔案很小(上面那個才是正常的)
需要在pom.xml新增配置:spring-boot-maven-plugin
SpringBoot打成jar包一般使用的就是spring-boot-maven-plugin這個外掛,當配置了該外掛後,執行“mvn package”進行打包時,會打包成一個可以直接執行的jar 檔案
<build>
<plugins>
<plugin>
< groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</ plugins>
</build>
報紅問題:
我的所有專案spring-boot-maven-plugin這一項都爆紅,但是在本地專案能正常執行。
我的報紅原因是缺少版本號,這個版本號要和專案的版本對應,不然還是會出現找不到的錯誤。例如我的專案是版本是2.3.2
在spring-boot-maven-plugin中加上
<version>2.3.2.RELEASE</version>
報紅問題解決
之後在重新打包部署即可。
jar包部署參考:
https://blog.csdn.net/weixin_44732379/article/details/115296564