Maven没有为Spring Boot项目创建META-INF [英] maven is not creating META-INF for spring boot project

查看:776
本文介绍了Maven没有为Spring Boot项目创建META-INF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我构建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>

推荐答案

两种方法.

  1. 形成 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.

  1. 插件的用法指出

从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆