在 Maven 中给出这个插件配置pom.xml
:
<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
失踪Implementation-Version
and Implementation-Title
,鉴于我可以获得的所有文档,要么不提及它,要么暗示它的创建是默认的?
完整生成的清单是:
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
显然,在幕后,spring-boot-maven-plugin
仍然依赖于创建的Manifestmaven-jar-plugin
,因为这是基础.jar
正在重新包装。
确定了这一点后,我们发现
从版本 2.1 开始,Maven Archiver 不再创建
默认情况下,清单中的实现和规范详细信息。
如果您希望它们出现在您的清单中,您必须在中明确说明
你的配置。 https://maven.apache.org/shared/maven-archiver/examples/manifest.html
因此,需要将以下内容添加到pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)