When running my jar file: java -jar target/places-1.0-SNAPSHOT.jar
I'm getting the next error :
no main manifest attribute, in target/places-1.0-SNAPSHOT.jar
The pom.xml
contains the spring-boot-maven-plugin
:
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.places.Main</mainClass> </configuration> </plugin>
I also tried to create a MANIFEST.MF
file and specifying the class, but it didnt help.
In addition, I also tried:
<properties> <!-- The main class to start by executing "java -jar" --> <start-class>com.places.Main</start-class> </properties>
Main class:
@SpringBootApplication public class Main { public static void main(String[] args) throws InterruptedException { SpringApplication.run(Main.class,args); } }
Any idea what else can I try?
In a Java project, every executable jar file contains a main method. Usually, it is placed at starting point of the application. To execute a main method by a self-executing jar file, we must have a proper manifest file and wrap it with our project at the proper location.
The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR.
The manifest attribute specifies the location of the document's cache manifest. HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection.
Try adding repackage
goal to execution goals.
Otherwise you would need to call the plugin explicitly as mvn package spring-boot:repackage
.
With the goal added, you have to call only mvn package
.
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.places.Main</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
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