Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage (de

question

Package the SpringBoot project, and the console reports an error

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage (default) on project springBootDemo: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to find main class -> [Help 1]

detailed question

For the package of the developed SpringBoot project, the console reports an error
insert image description here

solution

1. Do a global search for the current project.
2. Under the scope of In Project, search for @SpringBootApplication
3. If there are two or more @SpringBootApplications, this problem will occur. Check the project structure and delete the useless @SpringBootApplication annotation. The project file where the class is located
For the author, the specific operation is as follows:
1.
insert image description here
2. (The author here records after the event, that is, the problem has been solved, so there is only one, and the reader is likely to be two, or even more than two )
insert image description here
3 Delete the selected folderPlease add a picture description

solve the cause

For the startup of the SpringBoot project, it supports and only supports one startup class. The author probably chooses the wrong file location when creating the project, which leads to
conflicts with other projects, resulting in multiple SpringBoot startup classes, so that SpringBoot cannot confirm whether to run after packaging. Which startup class the project needs to use and which project to start.

chatgpt explain why

Check the source code in the project to ensure that only one class is marked with the @SpringBootApplication annotation. If there are multiple @SpringBootApplication annotations, it may be impossible to determine which class is the main class, thus causing this error. Just delete the classes and files where the redundant @SpringBootApplication annotations are located.

references

chatgpt

It’s not easy
to be original, please indicate the source
if it’s helpful to you, don’t forget to like it and support it
insert image description here

Guess you like

Origin blog.csdn.net/T_Y_F_/article/details/131238234