1、 Problem description
1.1 development environment configuration
pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--Be sure to match the springboot version number, because the new version of springboot no longer sets the dependencies of this plugin-->
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
1.2 error
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.17.RELEASE:repackage (default) on project taco-cloud-eureka-server: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.1.17.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.xxx.xxx.Application, com.xxx.xxx.Application]
II. Solution
2.1 Remove repackage
and use mainclass
instead
Configure in the top-level parent project pom.xml
<properties>
<! --needs to be overridden by subclasses to resolve multiple main methods-->
<mainClass>com.taco.springcloud.Application</mainClass>
</properties>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--Be sure to match the springboot version number, because the new version of springboot no longer sets the dependencies of this plugin-->
<version>${spring-boot.version}</version>
<configuration>
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
Override the mainclass
attribute in POM. XML
projects that need to be deployed as web projects
<properties>
<mainClass>com.taco.springcloud.TacoConfigServerApplication</mainClass>
</properties>
In this way, even if there are other main methods in the dependent package, no error will be reported
Similar Posts:
- SpringBoot Project Package Error: [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin (Running Normally)
- Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.5. RELEASE:repackage (repackage) on project tristone-boot-module-system: zip file is empty
- [Solved] SpringBoot Project Package to jar Error: ClassNotFound…
- How to Solve Error: spring-boot-maven-plugin not found
- [Solved] The updated version of springboot causes no main manifest attribute
- [Solved] SpringBoot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-res
- [Solved] Plugin ‘org.springframework.boot:spring-boot-maven-plugin:’not found
- [Solved] Spring Boot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0
- Spring cloud multi module packaging errors [How to Solve]
- Spring boot: run startup error [How to Solve]