关于spring boot web工程打jar包运行报主清单属性错误解决

关于spring boot web工程打jar包运行报主清单属性错误解决,第1张

关于spring boot web工程打jar包运行报主清单属性错误解决 关于spring boot web工程打jar包运行报主清单属性错误解决
.jar中没有主清单属性

先说解决方法

项目的pom.xml中添加打包插件


        
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    
                        
                            
                            repackage
                        
                        
                            false
                        
                    
                
            
        
    

原因:若没有添加这个插件,那么maven将会把项目打成普通的jar包,而普通的jar怎么会有spring boot的入口配置呢

入口程序配置,在jar包中的

meta-INF/MANIFEST.MF
Manifest-Version: 1.0
Implementation-Title: XXX_eureka
Implementation-Version: 1.0-SNAPSHOT
Built-By: XXX
Implementation-Vendor-Id: com.XXX
Created-By: Apache Maven 3.8.1
Build-Jdk: 1.8.0_201
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
 ot-starter-parent/xxx_parent/XXX_eureka

而且也没有将项目所依赖的jar包导入项目中。

而添加了插件后,maven就会将依赖以及启动入口添加到项目jar中。

在解压jar包后就会看到org的文件,且meta-INF/MANIFEST.MF的配置将会多出启动入口,即主属性配置信息

其中包含:Main-Class、Start-Class等等入口信息。

Manifest-Version: 1.0
Implementation-Title: XXX_eureka
Implementation-Version: 1.0-SNAPSHOT
Built-By: xxx
Implementation-Vendor-Id: com.XXX
Spring-Boot-Version: 2.1.4.RELEASE
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.XXX.eureka.EurekaApplication
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Created-By: Apache Maven 3.8.1
Build-Jdk: 1.8.0_201
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
 ot-starter-parent/XXX_parent/XXX_eureka

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/3984911.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-10-21
下一篇 2022-10-21

发表评论

登录后才能评论

评论列表(0条)

保存