Maven使用package打包Spring Boot時出現:Unable to find a single main class from the following candidates的問題解決


問題如下:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.5.RELEASE:repackage (default) on project information: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.5.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.hhly.InformationApplication, com.hhly.test.Application] -> [Help 1]

解決方法:

這個錯誤是因為Maven在執行打包的時候會查找項目中的main方法,並設置為Spring Boot生成JAR包的啟動入口,但此時有多個main方法,Maven插件就無法確認是用哪個。因此出現此異常。

1、注釋掉其他無用的main方法即可解決此問題。

2、在命令上指定入口:

mvn package -Dstart-class=com.jsoft.MainClass

 

參考:

http://www.cnblogs.com/xingzc/p/5972488.html

http://blog.csdn.net/yuechang5/article/details/52489911

https://segmentfault.com/a/1190000007462351


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM