解决 xx.jar中没有主清单属性 问题
2021-01-05 07:28
                         标签:tps   end   mave   我不知道   UNC   cat   build   删除   creat      今天新写的SpringBoot项目打jar包部署的时候遇到一个问题,xxx.jar包中没有主清单属性。如下图所示:      主清单属性是jar包中MANIFEST.MF文件中的一个属性,MANIFEST.MF文件位于jar包的META_INF路径下      打开MANIFEST.MF文件,里面有如下属性:   再贴一个正常的MANIFEST.MF:   对比发现有问题的jar包文件中多了Archiver-Version、Built-By、Implementation-Vendor-Id三个属性,少了Spring-Boot-Version、Main-Class、Start-Class、Spring-Boot-Classes、Spring-Boot-Lib五个Springboot相关的属性。   Main-Class:属性值代表了Spring Boot中启动jar包的程序,值为 org.springframework.boot.loader.JarLauncher,这个就是Springboot启动项目的类   Start-Class:属性值代表了Spring Boot程序的入口类,即XXXApplication类   Spring-Boot-Classes:属性值代表了类路径,所有编译后的class文件,以及配置文件,都存储在该路径下   Spring-Boot-Lib:属性值代表了表示依赖的jar包存储的位置   以上这些属性是Springboot打包插件默认生成,缺少这些属性项目无法运行。   所以需要再pom文件中添加Springboot打包插件:   按照一个正统的教程到这里应该就结束了,但是....   一顿操作之后你的项目可能会OK了,但也可能仍然有问题   我项目的POM文件是自动生成的在build标签里面附带了一个pluginManagement标签,我们知道pluginManagement一般是在父pom中,pluginManagement中包裹的插件,子pom可以直接引用,但也必须在子pom中写出来。当我百思不得其解的时候 ,我比较了我之前项目的pom文件,发现没有这个标签,然后我尝试删除pluginManagement标签之后。再次编译的jar包终于运行成功。这里pluginManagement的某种我不知道的特性可能对Springboot打包插件的生效产生了某种不可名状的干扰。   解决 xx.jar中没有主清单属性 问题 标签:tps   end   mave   我不知道   UNC   cat   build   删除   creat    原文地址:https://www.cnblogs.com/liumyblog/p/12982502.html

Manifest-Version: 1.0
Implementation-Title: com.imooc
Implementation-Version: 1.0-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: liu
Implementation-Vendor-Id: com.zh
Created-By: Apache Maven 3.6.3
Build-Jdk: 1.8.0_111
Implementation-URL: http://www.example.com
Implementation-Vendor: Pivotal Software, Inc.
Manifest-Version: 1.0
Implementation-Title: common
Implementation-Version: 0.0.1-SNAPSHOT
Spring-Boot-Version: 2.1.5.RELEASE
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.zh.common.management.CommonApplication
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Created-By: Maven Archiver 3.4.0
plugin>
  groupId>org.springframework.bootgroupId>
   artifactId>spring-boot-maven-pluginartifactId>
plugin>build>
    pluginManagement>
      plugins>
        
      plugin>
          groupId>org.springframework.bootgroupId>
          artifactId>spring-boot-maven-pluginartifactId>
        plugin>
      plugins>
    pluginManagement>
    plugins>
      plugin>
        groupId>org.apache.maven.pluginsgroupId>
        artifactId>maven-compiler-pluginartifactId>
        configuration>
          source>8source>
          target>8target>
        configuration>
      plugin>
    plugins>
  build>
文章标题:解决 xx.jar中没有主清单属性 问题
文章链接:http://soscw.com/index.php/essay/40211.html