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

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

.jar中没有主清单属性

先说解决方法

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

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <!--可以把依赖的包都打包到生成的Jar包中-->
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <attach>false</attach>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

原因:若没有添加这个插件,那么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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值