问题描述:springBoot 多项目在 idea 中可以正常启动,打包时报错找不到类,如下图
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project callcenter-utils: Compilation failure: Compilation failure: [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/dao/impl/IParameterDaoImpl.java:[3,45] 程序包com.hmzj.callcentercommon.singletable不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/dao/impl/IParameterDaoImpl.java:[14,40] 找不到符号 [ERROR] 符号: 类 BaseDao [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/entry/UtParameter.java:[3,45] 程序包com.hmzj.callcentercommon.singletable不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/entry/UtParameter.java:[4,56] 程序包com.hmzj.callcentercommon.singletable.annotation不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/entry/UtParameter.java:[13,34] 找不到符号 [ERROR] 符号: 类 IBaseEntry [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/dao/inter/IParameterDao.java:[3,45] 程序包com.hmzj.callcentercommon.singletable不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/dao/inter/IParameterDao.java:[11,40] 找不到符号 [ERROR] 符号: 类 IBaseDao [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/service/impl/SpeechToTextService.java:[5,38] 程序包com.hmzj.callcentercommon.http不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/service/impl/SpeechToTextService.java:[6,42] 程序包com.hmzj.callcentercommon.response不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/service/impl/SpeechToTextService.java:[7,42] 程序包com.hmzj.callcentercommon.response不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/service/inter/ISpeechToTextService.java:[3,42] 程序包com.hmzj.callcentercommon.response不存在 [ERROR] /D:/hmzj/tms-callcenter/callcenter-utils/src/main/java/com/hmzj/callcenterutils/service/impl/SpeechToTextService.java:[26,16] 找不到符号 [ERROR] 符号: 类 HttpResponse
分析:从 zuul 以上模块都可以打包成功,以下模块都失败因为都依赖了 callcenter-common,却找不到的类
百思不得其姐
解决: 给被依赖的模块 pom.xml 中增加如下: 打包成非可执行的 jar
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>exec</classifier> </configuration> </plugin> </plugins> </build>
参考文章: https://segmentfault.com/q/1010000011151233/a-1020000011151428
作者 @ 没有故事的老大爷
年少时的任性,有些话伤人不轻
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于