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>
Click 'Add Folder', click 'Create New Folder', type 'src/main/resources/META-INF', click 'Finish', click 'OK', Click 'Apply and Close', In the source folder '~/src/main/java', create a new Package 'hello' and a new Class file 'Application.
In src/main/resources , simply create a META-INF folder and place your files here. In this way, you could find them in the META-INF folder of the built JAR. Besides, you should remove the <resource> element you added in the pom.
The META-INF directory The manifest file that is used to define extension and package related data. This file is generated by the new "-i" option of the jar tool, which contains location information for packages defined in an application or extension.
This file contains meta data about the contents of the JAR. For example, there is an entry called Main-Class that specifies the name of the Java class with the static main() for executable JAR files. for more details. BOOT-INF : Spring Boot applications load from the BOOT-INF folder.
Two ways to do it.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With