docker no main manifest attribute

一、背景

  使用docker运行jar镜像时,报错:“docker no main manifest attribute”,其实在本地使用【java -jar】运行该jar包,同样会报错“xxxx.jar中没有主清单属性”。

二、原因

  打开jar包,可以发现文件夹【META-INF】中的文件【MANIFEST.MF】有问题,少了很多属性。

三、解决办法

  1. 手动添加对应的属性,对比下面正常的文件
    复制代码
    Manifest-Version: 1.0
    Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
    Implementation-Title: agent-web
    Implementation-Version: 0.0.1-SNAPSHOT
    Start-Class: com.xxx.AgentWebApplication
    Spring-Boot-Classes: BOOT-INF/classes/
    Spring-Boot-Lib: BOOT-INF/lib/
    Build-Jdk-Spec: 1.8
    Spring-Boot-Version: 2.3.0.RELEASE
    Created-By: Maven Jar Plugin 3.2.0
    Implementation-Vendor: Pivotal Software, Inc.
    Main-Class: org.springframework.boot.loader.JarLauncher
    复制代码
  2. 如果是maven项目,则可以增加【spring-boot-maven-plugin】插件,直接打包可以运行的jar包。
    复制代码
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
    <skipTests>true</skipTests>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    复制代码

     

posted @   从零开始的0  阅读(2216)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
点击右上角即可分享
微信分享提示