Unable to find a single main class from the following candidates

1.遇到的问题

进行mvn package报错

Unable to find a single main class from the following candidates [com.esoon.storage.WebdavServerApplication, com.esoon.storage.utils.DateTimeUtil]
 

2. 解决办法 

 去掉DateTimeUtil中的main方法

 3.终极解决办法

在pom.xml中加入如下代码

   <properties>
        <start-class>com.gary.WebdavServerApplication</start-class>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当Maven打包报错"Unable to find a single main class from the following candidates"时,意味着Maven无法从多个类中找到唯一的启动类。这个问题的解决方法如下: 1. 首先,需要确定项目中的哪个类是主启动类。在报错信息中,会列出多个备选的启动类,比如。根据你的需求,选择一个类作为主启动类。 2. 确认主启动类的位置,并且在项目的配置文件中指定该类为主启动类。具体来说,可以在pom.xml文件中的spring-boot-maven-plugin插件配置中添加<configuration>标签,并在其中指定主启动类的全限定名,比如com.zjq.xxxApplication。 3. 如果仍然报错,可能是因为项目中存在多个类都有main方法。在报错信息中提到了两个类com.xxx.analyze.LuckyLogAnalyzeApplication和com.xxx.analyze.consumer.FlinkESTest。这种情况下,需要删除一个类的main方法或者将其中一个类从启动类的备选列表中移除。 总结来说,解决这个问题的关键是确定一个唯一的主启动类,并在项目配置中指定该类。如果项目中存在多个类都有main方法,需要删除其中一个或者将其从启动类备选列表中移除。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [maven打包报错failed: Unable to find a single main class from the following candidates []](https://blog.csdn.net/qq_35427589/article/details/124382728)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Maven构建报错 repackage failed: Unable to find a single main class from the following candidates](https://blog.csdn.net/wstever/article/details/129680117)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值