问题描述
   
    
     SpringBoot项目本地运行正常,Maven打包报错:
    
    
     Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed
    
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) on project SpringCloudUserFeign: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.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 http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Process finished with exit code 1
    
    
    原因分析:
   
原因是添加该插件后编译打包时会自动寻找项目中的启动类,如果某个模块没有启动类或者有多个main启动类就会报错,通过保证模块启动类main启动类入口唯一也可以解决。
    
    
    解决方案:
   
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <!-- spring boot启动类的路径 -->
          <mainClass>com.test.ApplicationMain</executable>
        </configuration>
        <executions>
          <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
 
版权声明:本文为u011974797原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
