博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringBoot学习之一 Unable to find a single main class from the following candidates
阅读量:6707 次
发布时间:2019-06-25

本文共 4172 字,大约阅读时间需要 13 分钟。

在启动SpringBoot项目是报错

Unable to find a single main class from the following candidates [boot.myboot.SampleController, boot.myboot.App]

意思 是从这两个类中找不到要执行那个main方法

执行spring-boot:run -X打印出Debug日志

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.7.RELEASE:run (default-cli) on project myboot: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.7.RELEASE:run failed: Unable to find a single main class from the following candidates [boot.myboot.SampleController, boot.myboot.App] -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.7.RELEASE:run (default-cli) on project myboot: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.7.RELEASE:run failed: Unable to find a single main class from the following candidates [boot.myboot.SampleController, boot.myboot.App]    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:606)    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.7.RELEASE:run failed: Unable to find a single main class from the following candidates [boot.myboot.SampleController, boot.myboot.App]    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)    ... 20 moreCaused by: java.lang.IllegalStateException: Unable to find a single main class from the following candidates [boot.myboot.SampleController, boot.myboot.App]    at org.springframework.boot.loader.tools.MainClassFinder$MainClassesCallback.getMainClass(MainClassFinder.java:348)    at org.springframework.boot.loader.tools.MainClassFinder.findSingleMainClass(MainClassFinder.java:99)    at org.springframework.boot.maven.AbstractRunMojo.getStartClass(AbstractRunMojo.java:360)    at org.springframework.boot.maven.AbstractRunMojo.execute(AbstractRunMojo.java:170)    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)    ... 21 more[ERROR] [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

错误原因是因为:在这两个类中都包含main方法,所以项目在运行时不知大概执行那个main方法开始项目

 

解决方法:两个类中的main方法只保留一个

转载于:https://www.cnblogs.com/kuoAT/p/7806595.html

你可能感兴趣的文章
webpack系列之一总览
查看>>
乌龙事件之chrome页面部分白屏
查看>>
FP 视角下的领域驱动设计
查看>>
玩转iOS开发:iOS中的Socket编程(二)
查看>>
如何打造BCH使用的刚性需求?
查看>>
一个小需求引发的思考
查看>>
JSX,了解一下?
查看>>
升级Swift4 0遇到的坑
查看>>
第一本Python神经网络编程译著图书终于来啦
查看>>
四两拨千斤式的攻击!如何应对Memcache服务器漏洞所带来的DDoS攻击?
查看>>
2017 Material design 第四章第二节《单位和尺寸》
查看>>
2017 Material design 第一章第三节《Material特性》
查看>>
iOS开发笔记(三):消息传递与转发机制
查看>>
Python缓存技术
查看>>
Metal入门(使用Metal画一个三角形)
查看>>
浅谈 iOS 应用启动过程
查看>>
Clang 之旅—[翻译]添加自定义的 attribute
查看>>
零基础学习Web开发的入门需要掌握哪些?
查看>>
慎用System.nanoTime()
查看>>
2017 移动端 iOS 年终工作总结-纯干货请自备酒水
查看>>