Unable to find a single main class from the following candidates 问题解决

news/2024/12/14 16:48:59/

背景

maven父子工程间引用打包,产生的异常

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.12.RELEASE:repackage (repackage) on project shop-common: Execution repackage of goal org.springfr
amework.boot:spring-boot-maven-plugin:2.1.12.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.huanchuang.common.util.CommonAlgoUtil,
com.huanchuang.common.util.DateUtils, com.huanchuang.common.service.impl.MdSensorServiceImpl] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :shop-common

 解决

那如何解决呢

1.父子工程引用 

多模块依赖时,如果类似common之类的module只作为依赖包,而无需作为springboot的application时,以下打包插件不应配置到顶级pom及common的pom中

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

2.单一工程

在pom.xml文件中加入主类,用于指定加载的主类(用于告诉spring boot maven plugin哪个类是入口类即可)

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.huanchuang.commmon.Application</mainClass></configuration>
</plugin>

PS: 其中在打包的时候resources文件下所有的目录都会自动被打包,如果是没有加载上去,可以按照下面的方式指定静态文件

<resources><resource><directory>src/main</directory><includes><include>**/*.properties</include></includes><filtering>false</filtering></resource>
</resources>

 


http://www.ppmy.cn/news/628646.html

相关文章

Selective Search for Object Recognition

最近被老师弄去做图像方向,完全没相关经验,都是从论文看起。之后会整理我看的一系列论文,可能会有很多错误的地方,如果有发现,欢迎提出! 很多人问要代码,在文章结尾有分享。 Selective Search for Object Recognition 是J.R.R. Uijlings发表在2012 IJCV上的一篇文章。…

Flutter Error: The method ‘inheritFromWidgetOfExactType‘ isn‘t defined for the class ‘BuildContext‘.

异常 Androidstudio 编译运行导入别人的Flutter项目时报错&#xff0c;具体异常信息&#xff1a; D:/IDE/Flutter_windows_2.0.0-stable/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_redux-0.5.4/lib/flutter_redux.dart:77:19: Error: The method inheritFromWidg…

Correcting Chinese Spelling Errors with Phonetic Pre-training

语音预习矫正汉语拼写错误 张瑞清&#xff0c;庞超&#xff0c;张传强&#xff0c;王朔欢&#xff0c;何忠军、孙宇、吴华和海峰[1] 百度公司。中国北京上地10号街10号&#xff0c;100085{张瑞青奥尔&#xff0c;庞曹04&#xff0c;张川强&#xff0c;王寿环}http://baidu.co…

When Color Constancy Goes Wrong:Correcting Improperly White-Balanced Images阅读札记

When Color Constancy Goes Wrong: Correcting Improperly White-Balanced Images 阅读札记 论文发表于2019年的CVPR。 Abstract 本文方法主要解决校正白平衡不当的图像问题。校正白平衡不当问题真正难点不在于确定正确的白平衡是什么&#xff0c;而在于以下事实&#xff1a;相…

flutter2.1升级flutter3.0

下载最新fluttert版本 for github 升级kotlin版本 及 gradle版本 Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15. Failed to apply plugin ‘kotlin-android’. [ 4 ms] > The …

Correcting Over-Exposure in Photographs阅读札记

Correcting Over-Exposure in Photographs 阅读札记 论文发表于2010年的CVPR。 Abstract 本文方法通过分别恢复颜色和亮度来校正现有照片的曝光过度。 步骤&#xff1a;   &#xff08;1&#xff09;稍微压缩曝光良好区域的动态范围&#xff0c;为过度曝光区域的动态范围腾出…

see declaration of 'i'

unsigned int s; 可以是全局局部变量 随机数rand srand((unsigned)time(0)); //只能是局部变量 srand()%101;/只能是局部变量 否则会出现see declaration of i http://www.cctry.com/thread-36733-1-1.html 变量 i 重复初始化了

CONDITIONS EVALUATION REPORT

CONDITIONS EVALUATION REPORT spring boot 项目显示&#xff1a;CONDITIONS EVALUATION REPORT 原因&#xff1a;日志配置了level的属性 解决办法&#xff1a; 在配置文件application.yml或者application.properties文件中加入&#xff1a; logging.level.org.springframe…