Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Program cannot find main class

I have a program which runs as a Spring boot App in eclipse. The program was running fine. Then i did the following:

Right click on project -> Run As -> Maven Test .

This was accidental. When i then tried to run the program as a spring boot app again, it threw the following error below.

Error: Could not find or load main class com.bt.collab.alu.api.webapp.Application

How do i point the application back to my main class? Thanks

like image 512
Christopher Jobling Avatar asked Feb 11 '15 09:02

Christopher Jobling


People also ask

Where is the main class in spring boot application?

A Spring Boot application's main class is a class that contains a public static void main() method that starts up the Spring ApplicationContext. By default, if the main class isn't explicitly specified, Spring will search for one in the classpath at compile time and fail to start if none or multiple of them are found.

How resolve could not find or load main class in spring boot?

If you are running a Spring Boot based application and you are getting could not find or load main class in spring boot . Make sure your maven is building the classes properly and Java Home is set properly. Exception in thread “main” java. lang.


2 Answers

I had the same problem. Try this :

Right Click the project -> Maven -> Update Project

Then Re-run the project. Hope it work for you too.

like image 121
mantri Avatar answered Sep 21 '22 09:09

mantri


Main class is configurable in pom.xml

<properties>     <start-class>com.bt.collab.alu.api.webapp.Application</start-class> </properties> 
like image 21
MariuszS Avatar answered Sep 23 '22 09:09

MariuszS