chitwan
chitwan

Reputation: 263

maven is not creating META-INF for spring boot project

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>

Upvotes: 10

Views: 11043

Answers (2)

Mohammad Mayar Alam
Mohammad Mayar Alam

Reputation: 55

Adding below entry under <plugins> tag in pom.xml worked for me

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>

Upvotes: 0

Naman
Naman

Reputation: 31868

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>

Upvotes: 5

Related Questions