国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Spring Boot jar中沒有主清單屬性的解決方法

瀏覽:63日期:2023-09-16 11:53:35

使用Spring Boot微服務(wù)搭建框架,在eclipse和Idea下能正常運(yùn)行,但是在打成jar包部署或者直接使用java -jar命令的時(shí)候,提示了xxxxxx.jar中沒有主清單屬性:

D:hu-gitspring-xxx-xxxtarget>java -jar spring-cloud-eureka-0.0.1-SNAPSHOT.jar

spring-xxx-xxx-0.0.1-SNAPSHOT.jar中沒有主清單屬性

通過maven打jar包:mvn install, 或者在IDE中右擊選擇Run as -> maven install。在這里有一個(gè)問題就是主清單屬性是什么?以SpringBoot為例,jar包中包含了三個(gè)文件夾:BOOT-INF,META-INF,org,可以把jar包解壓到文件夾下查看,其中META-INF文件夾下有一個(gè)MANIFEST.MF文件,該文件指明了程序的入口以及版本信息等內(nèi)容,如下

Manifest-Version: 1.0Implementation-Title: spring-xxx-xxxImplementation-Version: 0.0.1-SNAPSHOTArchiver-Version: Plexus ArchiverBuilt-By: XXXXImplementation-Vendor-Id: com.huyikang.practiceSpring-Boot-Version: 1.5.9.RELEASEImplementation-Vendor: Pivotal Software, Inc.Main-Class: org.springframework.boot.loader.JarLauncherStart-Class: com.huyikang.practice.eureka.ApplicationSpring-Boot-Classes: BOOT-INF/classes/Spring-Boot-Lib: BOOT-INF/lib/Created-By: Apache Maven 3.5.2Build-Jdk: 1.8.0_151Implementation-URL: http://maven.apache.org Main-Class代表了Spring Boot中啟動jar包的程序 Start-Class屬性就代表了Spring Boot程序的入口類,這個(gè)類中應(yīng)該有一個(gè)main方法 Spring-Boot-Classes代表了類的路徑,所有編譯后的class文件,以及配置文件,都存儲在該路徑下 Spring-Boot-Lib表示依賴的jar包存儲的位置

這些值都是SpringBoot打包插件會默認(rèn)生成的,如果沒有這些屬性,SpringBoot程序自然不能運(yùn)行,就會報(bào)錯(cuò):jar中沒有主清單屬性,也就是說沒有按照SpringBoot的要求,生成這些必須的屬性。

解決辦法:

在pom中添加一個(gè)SpringBoot的構(gòu)建的插件,然后重新運(yùn)行 mvn install即可。

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>

在運(yùn)行mvn install的時(shí)候,自動生成這些主清單屬性,運(yùn)行java -jar xxx.jar時(shí)會根據(jù)主清單屬性找到啟動類,從而啟動程序。

到此這篇關(guān)于Spring Boot jar中沒有主清單屬性的解決的文章就介紹到這了,更多相關(guān)Spring Boot jar 主清單屬性內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 石城县| 肥乡县| 衡南县| 五寨县| 神农架林区| 尚义县| 廊坊市| 临夏市| 岚皋县| 金堂县| 崇阳县| 关岭| 千阳县| 龙州县| 封开县| 屯门区| 聂荣县| 江口县| 梨树县| 巴南区| 林州市| 安福县| 梧州市| 石棉县| 仪征市| 潍坊市| 鸡西市| 云龙县| 衢州市| 大邑县| 铜鼓县| 盘山县| 长武县| 珠海市| 武威市| 固镇县| 罗甸县| 文昌市| 伽师县| 土默特右旗| 义马市|