[SpringBoot] Spring-Boot: Run command Starts an error, unable to find a suitable main class, please add a ‘mainclass’

2023-03-18  

Use Maven command Spring-Boot: Run Start the SpringBoot project to report an error:

Unable to find a suitable main class, please add a ‘mainClass’ property

First of all, I can determine that I have no mistake. I can start the project through the Java class, but the Spring-Boot: RUN command cannot start the project.

1 First, add the POM configuration file plug -in setting according to the online suggestion:

   <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!-Add the following->
                <configuration>
                <mainClass>class_name</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

I have no effect after trying it

2 first start the SpringBoot project through the Java class

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

can be successfully started and keep starting status

execute Spring-Boot: Run command starts, the Spring icon will appear, but the error will be reported afterwards
At this time, turn off the threads startup of the Java class, and then execute the Spring-Boot: Run command to start.

This is how I started this.

source

Random Posts

Detailed explanation of the implementation of Call, Apply, and Bind in JS (source code implementation)

STM32CUBEMX+Keil+HAL Library (DMA+idle interruption and sending and receiving indefinite data) CZU

1 1 2 2330-Final Ugly English [Stack] PULLULATE

Solving the bug of IE6 IE7 onResize

-like pressure DP seeks the shortest road