记一次Springboot 启动错误(三) xxx.jar中没有主清单属性

解决方式:

在pom.xml中添加

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

原因:

在打jar包时   jar中包含了三个文件夹:BOOT-INF,META-INF,org,可以把jar包解压到文件夹下查看,其中META-INF文件夹下有一个MANIFEST.MF文件,该文件指明了程序的入口以及版本信息等内容

Main-Class代表了Spring Boot中启动jar包的程序Start-Class属性就代表了Spring Boot程序的入口类,这个类中应该有一个main方法Spring-Boot-Classes代表了类的路径,所有编译后的class文件,以及配置文件,都存储在该路径下Spring-Boot-Lib表示依赖的jar包存储的位置这些值都是SpringBoot打包插件会默认生成的,如果没有这些属性,SpringBoot程序自然不能运行,就会报错:jar中没有主清单属性,也就是说没有按照SpringBoot的要求,生成这些必须的属性。
 

MANIFEST.MF文件中的信息:

Manifest-Version: 1.0
Implementation-Title: spring-xxx-xxx
Implementation-Version: 0.0.1-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: XXXX
Implementation-Vendor-Id: com.huyikang.practice
Spring-Boot-Version: 1.5.9.RELEASE
Implementation-Vendor: Pivotal Software, Inc.
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.huyikang.practice.eureka.Application
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Created-By: Apache Maven 3.5.2
Build-Jdk: 1.8.0_151
Implementation-URL: http://maven.apache.org

猜你喜欢

转载自blog.csdn.net/weixin_42059737/article/details/86383793
今日推荐