SpringBoot多模块项目打包失败 Unable to find main class

spring boot多模块项目打包失败:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.2.RELEASE:repackage (repackage) on project xxx: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.2.RELEASE:repackage failed: Unable to find main class -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn  -rf :xxx

问题原因:

因为各模块pom.xml集成了 父模块,在打包时,在没有指定 mainClass 入口时,会找所有子模块下的 main 方法,若未找到,会导致打包异常,找不到main类。

解决方式:

模块指定对应的 main 入口即可。

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    com.package.ProjectApplication
                
                
                    
                        
                            
                            repackage
                        
                    
                
            
        
    

 

你可能感兴趣的:(Java杂记,spring,boot)