Java – SpringBoot no main manifest attribute (maven)

javamanifestmavenspring-bootspring-boot-maven-plugin

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

My 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>

My main :

@SpringBootApplication
 public class Main {
public static void main(String[] args) throws InterruptedException {
    SpringApplication.run(Main.class,args);
  }
  }

any idea what else can I try ?

Best Answer

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>