Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpringBoot no main manifest attribute (maven)

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?

like image 896
JeyJ Avatar asked Feb 25 '19 13:02

JeyJ


People also ask

What is no main manifest attribute?

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.

Where is spring boot manifest file?

The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR.

What is manifest attribute?

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.


1 Answers

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> 
like image 73
Matej Avatar answered Sep 19 '22 14:09

Matej