Skip to content
Advertisement

Failed to load Main-Class manifest attribute while running java -jar

I have successfully built my Spring MVC project with mvn clean package by following this tutorial.

Now I am trying to run the service with:

mvn clean package && java -jar target/gs-serving-web-content-0.1.0.jar

But I get this error:

Failed to load Main-Class manifest attribute from target/gs-serving-web-content-0.1.0.jar

Am I missing something?

Advertisement

Answer

If you are working with Spring Boot this will solve your problem:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.2.5.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Reference Guide | Spring Boot Maven Plugin

Advertisement