maven is not creating META-INF for spring boot project

戏子无情 提交于 2019-12-24 03:34:25

问题


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:


Two ways to do it.

  1. Form the maven-jar-plugin documentation :

Please note that the following parameter has been completely removed from the plugin configuration:

useDefaultManifestFile

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>

where in you can place your MANIFEST.MF under src/main/resources/META-INF folder of your project. The command

mvn clean package

would build the project jar with the src/main/resources by default.

  1. The notes at usage of the plugin states that

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.

Which can be done using:

<manifest>
     <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
     <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>


来源:https://stackoverflow.com/questions/46198001/maven-is-not-creating-meta-inf-for-spring-boot-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!