"Error: Could not find or load main class" in a Module of Spring Boot

3661 views java
3

I have a Spring Boot app that is in a Module within a project.

The module has its own pom.xml and the outer project has its own pom.xml

The module's pom.xml has the <mainClass>...</mainClass> annotation pointing to the main class of the app.

It also has a reference to the parent pom.xml with the <parent>...</parent> property, pointing to the parent artifactId, groupId & version.

When running the app within Intellij, it runs OK.

The problem is when trying to run the app from the jar:

 java -jar myApp.jar

Then we get and error of

Error: Could not find or load main class com.example.application

What are we missing here?

answered question

Can you provide your pom.xml?

1 Answer

6

Open your jar file with winzip or winrar, if you are using linux use archive manager. Then go to the META-INF, open the MANIFEST.MF and make sure that the property "Main-Class: your.class.path" is correct.

posted this

Have an answer?

JD

Please login first before posting an answer.