一、项目背景
在联系SpringCloud 是为了方便复制module,生成多个module时报错
二、报错展示
2022-11-16 09:03:09.949 INFO 44700 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-11-16 09:03:09.952 ERROR 44700 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'placeholderConfigurer', defined in net.biancheng.c.MicroServiceCloudProviderDept8001Application, could not be registered. A bean with that name has already been defined in class path resource [net/biancheng/c/MicroServiceCloudProviderDept8002Application.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Process finished with exit code 0
三、原因分析
复制的项目或者复制module时,有些module相应的配置没有及时刷新,导致编译路径指向,造成不同的module或者project拥有同一个编译路径,出现重复,如果要是仔细查看报错文字,也应该能猜出一二:
net.biancheng.c.MicroServiceCloudProviderDept8001Application, could not be registered. A bean with that name has already been defined in class path resource [net/biancheng/c/MicroServiceCloudProviderDept8002Application.class] and overriding is disabled.
四、纠错方案
把项目输出地址更改成项目对应的地址:(图一变成图二)
图一如下:
图二如下:
运行成功。
五、后话
文中所写不符合逻辑或者不严谨之处,恳望007们海涵;本着知其然,知其所以然的态度,诚请007们留言指正,以免误导他人,若仍未解决大家的问题,望去他处拜询,并翘盼回来留言补充