首页 > 编程语言 > 详细

Spring boot: 运行maven打包的jar包报错-jar中没有主清单属性

时间:2018-12-28 15:09:21      阅读:1021      评论:0      收藏:0      [点我收藏+]

使用mvn package打jar包,运行java -jar XXX.jar的时候报错:jar中没有主清单属性。

解决办法:

pom.xml中添加

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

再次运行mvn package之后,即可正常运行。

PS:

jar包多了BOOT-INF文件夹,里面包含class和依赖项。而且META-INF\MANIFEST.MF文件由

Manifest-Version: 1.0
Implementation-Title: restsample
Implementation-Version: 1.0-SNAPSHOT
Built-By: ZJ
Implementation-Vendor-Id: com.myproject
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_161
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
 ot-starter-parent/restsample

变为

Manifest-Version: 1.0
Implementation-Title: restsample
Implementation-Version: 1.0-SNAPSHOT
Built-By: ZJ
Implementation-Vendor-Id: com.myproject
Spring-Boot-Version: 2.0.5.RELEASE
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.myproject.restsample.RestSampleClass
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_161
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
 ot-starter-parent/restsample

 

参考:

https://blog.csdn.net/u010429286/article/details/79085212

 

Spring boot: 运行maven打包的jar包报错-jar中没有主清单属性

原文:https://www.cnblogs.com/jane850113/p/10190510.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!