一、問題
當執行java -jar xxx.jar命令時,出現jar中沒有主清單屬性
# 二、問題分析
BOOT-INF:主要包括項目class文件和項目依賴的lib jar文件
META-INF:主要是項目的pom.xml文件和清單屬性文件
org.springframework.boot.*:主要存放spring的一下相關.class文件
清單屬性是在打包是被maven自動打包進jar包中的,沒有清單屬性,說明maven install 打包時沒有執行成功。
清單屬性
Manifest-Version: 1.0 //版本
Implementation-Title: blog-web //jar名稱
Implementation-Version: 2.2.2 //jar版本號
Built-By: Progress//構建者
Implementation-Vendor-Id: com.blog
Spring-Boot-Version: 2.0.8.RELEASE //spring-boot 版本
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.zyd.blog.BlogWebApplication //程序啓動類
Spring-Boot-Classes: BOOT-INF/classes/ //代碼.class文件位置
Spring-Boot-Lib: BOOT-INF/lib/ //依賴jar存放位置
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_121 //JDK版本
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
ot-starter-parent/blog/blog-web
三、解決
問題排查:
-
pom.xml
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.blog.BlogWebApplication</mainClass> <layout>JAR</layout> <!--構建完整可執行程序,可以直接運行--> <executable>true</executable> </configuration> </plugin>
檢查pom.xml中是否配置了spring-boot-maven-plugin插件
-
maven 環境
點擊刷新按鈕,查看是否有爲安裝的maven插件;點擊clean清理項目;
點擊install,確保下載的相關jar文件都下載成功,並查看是否編譯成jar文件;
解壓jar文件,查看是否有清單屬性文件。