启动报错:
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'xxxxMapper' for bean class [org.springblade.xxx.mapper.xxxxMapper] conflicts with existing, non-compatible bean definition of same name and class [org.springblade.yyy.mapper.xxxxMapper]
尝试在问题模块加入
@ComponentScan(nameGenerator = CustomNameGenerator.class)
@MapperScan(nameGenerator = CustomNameGenerator.class)
自定义的nameGenerator 生成方法也不行。
```java
@SpringCloudApplication
@EnableFeignClients(AppConstant.BASE_PACKAGES)
@ComponentScan(nameGenerator = CustomNameGenerator.class)
@MapperScan(nameGenerator = CustomGenerator.class)
public class xxxxApplication {
public static void main(String[] args) {
BladeApplication.run(ModuleConstant.MODULE_XXXX, xxxxApplication .class, args);
}
}```
Spring容器是不会去判断同名的Mapper是否属于不同数据源,它只会判断这俩是否同名,是否有冲突。
所以为了解决这个问题,最简单的就是对Mapper进行改名,解决重名后自然就不会有冲突了。
如果一定要重名,那调用的时候需要用注解指定,具体可以看:https://blog.csdn.net/liuyueyi25/article/details/83280239