问题
I'm currently following John Thompson's Spring Framework Beginner to Guru course. I follow his step by step procedures on creating multi module maven project for spring pet clinic on spring boot. When I clicked package on my root module it says repackaged failed, unable to find main class.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:repackage (repackage) on project pet-clinic-data: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:repackage failed: Unable to find main class -> [Help 1]
回答1:
you are using spring-boot-maven-plugin:2.1.6.RELEASE.
since Spring-Boot 2 you don't need the spring boot plugin anymore.
you can use the following code after declaring the artifact id of your module.
<artifactId>pet-clinic-data</artifactId>
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
回答2:
Remove
<configuration>
<skip>true</skip>
</configuration>
and add "spring-boot.repackage.skip" property like the following:
<artifactId>pet-clinic-data</artifactId>
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
回答3:
Error speaks for itself. The executor cannot find your main class. It has nothing to do with your pom.xml. but has everything to do with the environment you are using to build and run your spring boot project.
If you are using IntelliJ, go to Run/Debug configuration
(Add configuration
on the screenshot, in your case it could be something else) and make sure your main class exits. Then tap your shift two times and type Invalidate Caches/Restart
and do both. Then it should work as expected.
回答4:
The spring-boot-maven-plugin should only be in the pom.xml of the module that contains the main class. It looks like you have this plug in on (or inherited by) a simple jar module that the main module will use as a dependency.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
The main class is annotated with @SpringBootApplication
来源:https://stackoverflow.com/questions/57187588/spring-boot-multi-module-maven-project-repackage-failed