Maven没有为Spring Boot项目创建META-INF [英] maven is not creating META-INF for spring boot project
问题描述
当我构建Spring引导项目时,它会创建一个目标文件夹并 目标/类,但它不会创建任何META-INF.我还包括了依赖项-
When I build my Spring boot project, it creates an target folder and target/classes also, but it doesn't create any META-INF. I have also included dependency -
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
<key>value</key>
</manifestEntries>
</archive>
</configuration>
推荐答案
两种方法.
- 形成 maven-jar-plugin 文档:
请注意,以下参数已被完全删除 通过插件配置:
Please note that the following parameter has been completely removed from the plugin configuration:
useDefaultManifestFile
如果您需要定义自己的MANIFEST.MF文件,则可以简单地实现 通过Maven Archiver配置,如以下示例所示:
If you need to define your own MANIFEST.MF file you can simply achieve that via Maven Archiver configuration like in the following example:
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
您可以在其中将MANIFEST.MF
放置在项目的src/main/resources/META-INF
文件夹下.命令
where in you can place your MANIFEST.MF
under src/main/resources/META-INF
folder of your project. The command
mvn clean package
默认情况下将使用src/main/resources构建项目jar.
would build the project jar with the src/main/resources by default.
-
插件的用法指出
从2.1版开始,maven-jar-plugin使用Maven Archiver 3.1.1.这意味着默认情况下,它不再在清单中创建规范和实现"详细信息.如果你想要他们 您必须在插件配置中如此明确地说.
Starting with version 2.1, the maven-jar-plugin uses Maven Archiver 3.1.1. This means that it no longer creates the Specification and Implementation details in the manifest by default. If you want them you have to say so explicitly in your plugin configuration.
可以使用以下方法完成
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
这篇关于Maven没有为Spring Boot项目创建META-INF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!