使用springboot+maven出现的问题

问题描述:
springboot 在执行maven install 时候出现以下错误

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) on project springcloud-common: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.itmuch.cloud.common.Application, com.itmuch.cloud.common.utils.SmsUtils] -> [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

解决办法:
1、在pom.xml文件中加入主类,用于指定加载的主类(在properties中,加入一个start-class的属性,用于告诉spring boot maven plugin哪个类是入口类即可)


        com.itmuch.cloud.common.Application
    

2、在build中添加如下配置


  ...
  
    ...
    
      org.springframework.boot
      spring-boot-maven-plugin
      1.4.0.RELEASE
      
        ${start-class}
        ZIP
      
      
        
          
            repackage
          
        
      
    
    ...
  
  ...

最好执行maven install即可

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.173 s
[INFO] Finished at: 2017-07-01T23:46:02+08:00
[INFO] Final Memory: 23M/277M
[INFO] ------------------------------------------------------------------------

你可能感兴趣的:(springboot,maven,springboot)