I. Description of the problem
When I use the Maven aggregation project to package the parent project for packaging, I get an error :Unable to find main class which probably means that the main startup class cannot be found
2. How to Solve
The project contains modules of some tool classes, and the tool class modules do not need us to be started, It is only provided for other interface service references, No need to start means no main startup class, but the pom file of the parent project references the springboot packaging plugin spring-boot-maven-plugin, namely:
<plugins>
<plugin>
<groupId>org.springframework.boot</ groupId>
<artifactId>spring-boot-maven-plugin< ;/artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId> ;
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
So when packaging, mvn will scan all dependent modules. If it finds that there is no main startup class under a module, it will report an error.
3. Solution
My solution is: Comment out the packaged plugin spring-boot-maven-plugin of the parent project and then package/install it
You can see that the packaging is successful
Read More:
- Java error: unable to find or load main class (package name in source file)
- Maven project running servlet jump JSP error: HTTP status 500 – unable to compile class for JSP
- [Solved] SpringBoot Pack Project: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
- Java Running Error: Could not find or load main class
- Maven Project Right-Click -update project Error [How to Solve]
- [Solved] MVN Build Project Error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test
- [Solved] org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject…
- [Solved] Spring Boot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0
- [Solved] IDEA Start Maven Project Error: “Error starting ApplicationContext. To display the conditions report …”
- [Solved] Error:Maven Resources Compiler: Maven project configuration required for module ‘XX‘ isn‘t available
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on
- Springboot Project Error: Failed to execute goal org.apache.maven.plugins
- [Solved] O2oa compile error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- IDEA Create maven project error: Error running‘[org.apache.maven.pluginsmaven-archetype-pluginRELEASE
- [Solved] Idea Failed to recognize Maven and Project Error
- Maven (http://repo1.maven.org/maven2/): Failed to transfer file and PKIX path building failed: sun.secu
- [Solved] Maven Multi-Project Compile Error: The POM for xxx is invalid
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:analyze-only
- [Solved] Springboot Project Startup Error: Unable to Identify bootstrap.yml Configuration