Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

intermittent "No main class is found." errors from the Spring Boot Dashboard in visual studio code

I’m just getting started with Java and I prefer Visual Studio Code over Eclipse. I downloaded the popular Java extensions for it including the Spring Boot tools (including Dashboard). When I switch to the Spring Boot Dashboard and click the Run or Debug button, I sometimes get a "No main class is found." popup error message and nothing starts. If I restart vscode, sometimes it works with the project that previously didn’t, but another project that worked in the past is now throwing this error. It doesn’t always happen with the same project. It all seems very random about when this exception is thrown. I have about 6 microservices projects (Eureka discovery, gateway, config server, different business logic), and it’s hard to get all 6 to start. I can reliably start them with the default Run and Debug option or via jars – and they all always work.

All the projects were created with Spring Initializr and they do indeed have a main function:

package ...;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class ...ApiGatewayApplication {

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is a known issue with Vscode :

https://github.com/microsoft/vscode-java-debug/issues/606

And the workaround solution is, install Code Runner Extension :

https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

then, click Run icon in the upper right-hand corner,press F1, Clean the java language server workspace.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading