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?
check the order of
it should be above
dockerfile-maven-plugin else repackage will happen
this solved my problem of no main attribute in manifest.
You are missing
maven-jar-plugin
in which you need to addmanifest
tag.You have to specifiy it in your pom.xml - This will make your jar executable with all dependencies (replace
your.main.class
):Use
spring-boot-maven-plugin
and be sure you set
property start-class
in the pom.xmlAlternatively, the main class can be defined as the mainClass element of the spring-boot-maven-plugin in the plugin section of your pom.xml:
You might be missing Spring Boot Maven Plugin.
I had the
spring-boot-maven-plugin
but still I was getting the error regarding main class.Finally I had to use the
maven-jar-plugin
and add themainClass
And it was good to go!