【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

时间:2024-07-02 14:37:02

>>>>spring cloud 多模块

>>>>在idea上使用maven插件打包,欲打包成jar包后 进行部署

>>>>

报错:程序包XXX不存在

==============================================================================

OK,开始研究这个问题:

1.服务开始打包啦,先使用clean进行清理

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

一般清理都会成功,就是删除target目录下的编译的class文件以及配置等

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

2.开始使用install进行打包的操作

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

开始打包,控制台显示日志:

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

但是 报错来的也很突然:

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

也就是说,明明程序包是存在的,但是依旧报错:

[ERROR]COMPILATIONERROR:
[INFO]-------------------------------------------------------------
[ERROR]/D:/document/IdeaProjects/springcloud/springcloud-ms-gateway/src/main/java/com/swapping/springcloud/ms/gateway/fallback/UniVerFallback.java:[,]程序包com.swapping.springcloud.ms.core.response不存在
[ERROR]/D:/document/IdeaProjects/springcloud/springcloud-ms-gateway/src/main/java/com/swapping/springcloud/ms/gateway/filter/AuthFilter.java:[,]程序包com.swapping.springcloud.ms.core.response不存在
[INFO]2errors
[INFO]-------------------------------------------------------------
[INFO]------------------------------------------------------------------------
[INFO]ReactorSummary:
[INFO]
[INFO]springcloud0.0.1-SNAPSHOT.........................SUCCESS[.342s]
[INFO]springcloud-ms-core................................SUCCESS[.748s]
[INFO]springcloud-ms-eureka..............................SUCCESS[.148s]
[INFO]springcloud-ms-gateway.............................FAILURE[.166s]
[INFO]springcloud-ms-hystrix-turbine.....................SKIPPED
[INFO]springcloud-ms-sleuth-zipkin.......................SKIPPED
[INFO]tx-manager4.2.0...................................SKIPPED
[INFO]springcloud-ms-member..............................SKIPPED
[INFO]springcloud-ms-goods...............................SKIPPED
[INFO]springcloud-ms-integral............................SKIPPED
[INFO]springcloud-ms-test0.0.1-SNAPSHOT.................SKIPPED
[INFO]------------------------------------------------------------------------
[INFO]BUILDFAILURE
[INFO]------------------------------------------------------------------------
[INFO]Totaltime:.002s
[INFO]Finishedat:--11T21::+:
[INFO]------------------------------------------------------------------------
[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-compiler-plugin:3.7.:compile(default-compile)onprojectspringcloud-ms-gateway:Compilationfailure:Compilationfailure:
[ERROR]/D:/document/IdeaProjects/springcloud/springcloud-ms-gateway/src/main/java/com/swapping/springcloud/ms/gateway/fallback/UniVerFallback.java:[,]程序包com.swapping.springcloud.ms.core.response不存在
[ERROR]/D:/document/IdeaProjects/springcloud/springcloud-ms-gateway/src/main/java/com/swapping/springcloud/ms/gateway/filter/AuthFilter.java:[,]程序包com.swapping.springcloud.ms.core.response不存在
[ERROR]->[Help1]
[ERROR]
[ERROR]Toseethefullstacktraceoftheerrors,re-runMavenwiththe-eswitch.
[ERROR]Re-runMavenusingthe-Xswitchtoenablefulldebuglogging.
[ERROR]
[ERROR]Formoreinformationabouttheerrorsandpossiblesolutions,pleasereadthefollowingarticles:
[ERROR][Help1]http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR]Aftercorrectingtheproblems,youcanresumethebuildwiththecommand
[ERROR]mvn<goals>-rf:springcloud-ms-gateway

那么这个问题怎么解决呢?

3.解决方法

最快捷简单的办法,就是将父级项目的pom.xml文件中,的maven插件注释,【只保留子模块的插件即可】【我这里子级模块中都没有显示加入插件,所以只注释了父级项目中的maven插件,就可以打包成功了】即可

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

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

然后再进行打包操作,即可成功:

【spring cloud】【IDEA】【maven】spring cloud多模块在idea上使用maven插件打包报错:程序包XXX不存在

4.同时需要注意,子模块的pom.xml文件中需要指定插件

参考地址:https://www.cnblogs.com/sxdcgaq8080/p/10130621.html