You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

spring-boot-maven-plugin repackage后MANIFEST.MF缺失指定属性咨询

问题背景

所用Maven插件配置

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <mainClass>acme.Main</mainClass>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

生成的MANIFEST.MF内容

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.8.6
Built-By: stewart
Build-Jdk: 17.0.5
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: acme.Main
Spring-Boot-Version: 2.7.5
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx

查阅相关文档后,要么未提及Implementation-Version与Implementation-Title属性,要么表明这些属性默认会被生成,但执行repackage后生成的MANIFEST.MF中却缺少这两个属性,请问出现该情况的原因是什么?


原因分析
  • Spring Boot Maven插件的repackage目标核心是生成可执行JAR包,它默认只在Manifest中添加启动相关的必要属性(比如Main-Class、Start-Class、Spring Boot版本信息等),不会自动把Maven项目的name、version属性映射到Implementation-Title和Implementation-Version上。

  • 标准的maven-jar-plugin确实会默认生成这两个属性:Implementation-Title对应项目的name字段,Implementation-Version对应项目的version字段。但Spring Boot的repackage操作会基于原jar插件生成的JAR重新打包,并用自己的启动专用Manifest覆盖原有的Manifest内容,导致原有的Implementation-*属性被丢弃。

  • 若要让这两个属性出现在最终的MANIFEST.MF中,必须手动配置Spring Boot Maven插件的manifest节点明确指定属性来源,或者配置maven-jar-plugin生成属性后,让Spring Boot插件保留原Manifest的元数据。


内容的提问来源于stack exchange,提问作者Stewart

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 03:25:30