SpringBoot学习之一 Unable to find a single main class from the following candidates

摘要:
启动SpringBoot项目时,会报告以下手册[boot.myboot.SampleController,boot.myboot.App]中的错误Unabletofindasinglemainclass。这意味着您无法从这两个类中找到要执行的main方法。执行spring引导:运行X打印调试日志[错误]Failedtoexecutegoal.org

在启动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 classfrom 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 classfrom 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)
    ... 20more
Caused by: java.lang.IllegalStateException: Unable to find a single main classfrom 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)
    ... 21more
[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方法只保留一个

免责声明:文章转载自《SpringBoot学习之一 Unable to find a single main class from the following candidates》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇15. Unity NGUI核心组件之UIPanel3DMAX中坐标解析下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

vue3.0打包后页面空白,放置服务器

lintOnSave:true,//配置跨域devServer:{open:true、host:'localhost'、port:3000、https:false,//以上IP地址和端口是我们计算机的本地地址;以下是需要跨域的代理:{//配置跨域名“/api”:{target:”http://106.12.148.51',//这里的背景地址是模拟的;您应该填...

IPI 通信(SMP)【转】

在MIPS架构下的IPI通信被关闭和中断后,IPIMIPS接口结构平台也将被发送_ smp_Ops{void;void;…}IPI通信是多个处理器之间的通信。send_ ipi_Single:一对一聊天send_ ipi_Mask:Mask posting,Mask表示Mask posting/*Octeon Tellanothercore of Lushi...

MySQL锁详解

MySQL锁详解update语句执行流程MySQL的锁介绍按照锁的粒度来说,MySQL主要包含三种类型(级别)的锁定机制:全局锁:锁的是整个database。由MySQL的SQLlayer层实现的表级锁:锁的是某个table。由MySQL的SQLlayer层实现的行级锁:锁的是某行数据,也可能锁定行之间的间隙。...

面试了一个 31岁的iOS开发者,思绪万千,30岁以上的程序员还有哪些出路?

前言之前HR给了我一份简历,刚看到简历的第一眼,31岁?31岁,iOS开发工程师,工作经历7年,5年左右都在外包公司,2年左右在创业公司。iOS开发工程师这块,还是很少遇到30岁以上的开发,正好,来了一个30岁的开发,说实话,对我来说,还是蛮期待的,希望对我有所启示。这样的过程持续了半个小时那么年过350岁的程序员还有出路吗?作为一个8年的iOS开发,而且几...

硬中断与软中断的区别!

在多核系统上,一个中断通常只能中断一个CPU(也有一种特殊情况,即主机上有一个硬件通道。它可以在没有主CPU支持的情况下同时处理多个中断。软中断:1。软中断与硬中断非常相似。生成软中断的进程必须是当前正在运行的进程,因此它们不会中断CPU。...

Python-正则

,三:量词*重复0次或多次{0,}+重复一次或多次{1,}?重复0或1次{1,0}{n}重复n次{n}{n,}重复n次,或更多次{n,m}将n次重复到m次Escape:如果字符串中有特殊字符要匹配,请在常规字符和字符串前面添加r。如果特殊字符在字符组中,则它们是匹配的特殊字符,但为了记忆,匹配时会转义所有特殊字符。...