异常详情
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project ******:
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run failed:
Unable to find a single main class from the following candidates [utils.UniqueStringUtils, utils.UniqueStringUtil, utils.DateUtil, utils.Base64, cn.yzstu.*]
场景描述
今天在做一个小功能的时候,新开了一个项目做测试,期间copy了一些工具类到新项目中,一切准备就绪,命令:mvn spring-boot:run *,运行项目,出现以上报错。
解决办法
异常的主要信息在最后一行:Unable to find a single main class from the following candidates,翻译过来就是“在以下候选中找到不止一个main类”,去报错信息中给出的类中查找
在这个类里有我以前测试留下来的main方法,注释掉,同样的去其他几个类里面。找到main方法注释掉(针对新人:主main需要留下)。
问题解决
完事儿后可以正常运行。
总结
maven在执行打包的时候会查找项目中的main方法,并设置为Spring boot 生成jar包的启动入口,但此时有多个main方法,maven插件就无所适从了。因此出现此异常。
因此,注释掉其他无用的main方法即可解决此问题。
来源:CSDN
作者:Baldwin_KeepMind
链接:https://blog.csdn.net/shouchenchuan5253/article/details/104813671