MangoCool

Unable to find a single main class from the following candidates [com.xx.xxApplication, com.xx.Application]

2024-03-04 15:31:49   作者:anobody   来源:MangoCool

编译出错:Unable to find a single main class from the following candidates [com.xx.xxApplication, com.xx.Application]

解释:根据该项目的配置,编译打包时需要指定一个程序的main执行入口,但目前发现有两个

解决方法:

1. 如果你的程序需要main执行入口,可以在pom中配置maimClass指定你需要的执行入口,如下:

<plugin>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-maven-plugin</artifactId>
	<configuration>
		<maimClass>com.xx.xxApplication</maimClass>
	</configuration>
</plugin>

2. 如果你的程序需要main执行入口,那么检查一下pom配置是否有问题,是不是有父工程,父工程中是否要求main执行入口,比如:

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.7.18</version>
	<relativePath/>
</parent>

标签: mvn、compile

分享:

上一篇springboot从2.4.10升级到2.7.18后,nginx代理访问,接口请求404问题

下一篇maven命令如何install tests.jar类型的jar包

关于我

崇尚极简,热爱技术,喜欢唱歌,热衷旅行,爱好电子产品的一介码农。

座右铭

当你的才华还撑不起你的野心的时候,你就应该静下心来学习,永不止步!

人生之旅历途甚长,所争决不在一年半月,万不可因此着急失望,招精神之萎葸。

Copyright 2015- 芒果酷(mangocool.com) All rights reserved. 湘ICP备14019394号

免责声明:本网站部分文章转载其他媒体,意在为公众提供免费服务。如有信息侵犯了您的权益,可与本网站联系,本网站将尽快予以撤除。