Leandro Borges Ferreira
Leandro Borges Ferreira

Reputation: 12792

How to run Spring boot application with STS

I am starting to learn microservices with Spring Boot. I go to root of my project and run the command:

mvn spring-boot:run

It works just fine and I can use my endpoints in localhost:8080/[path]. But when I try to run my project from the IDE using Run as -> Spring Boot App. I get this error:

Error: Could not find or load main class 

I could just use command line, but I really would like to know why I getting this error with the IDE. So, what I have to do to run my project from the IDE?

Edit 1:

There is my Main Class:

package br.com.leandroborgesferreira.microlearn;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MicroLearnApplication {

    public static void main(String[] args) {
        SpringApplication.run(MicroLearnApplication.class, args);
    }
}

Any help is appreciated!

Upvotes: 1

Views: 18930

Answers (3)

Ishmael Mavor Raines
Ishmael Mavor Raines

Reputation: 330

Enter spring-boot:run in your configuration if using Spring Tools Suite 4 IDE

enter image description here

Upvotes: 0

pramod singh
pramod singh

Reputation: 511

just right click within main class and run as > spring boot/java application

Upvotes: 1

Solorad
Solorad

Reputation: 914

I had the same problem. In my case problem was in default maven configurations in Intellij Idea. Go to settings and Settings -> Build Execution, Deployment -> Maven. Set maven home directory to correct one, not bundled with IJ IDEA. Right Click the project -> Maven -> Reimport Then Re-run the project. Hope it work for you too.

Also, please check Working directory in 'Run Configuration'. It should be something like "MODULE_DIR"

Upvotes: 0

Related Questions