springboot整合mybatis的时候多数据源使用

289 阅读1分钟

dataSource or dataSourceClassName or jdbcUrl is required

image.png 除了检查application.yml还要检查config的问题

image.png

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

image.png

这样子的问题大概是配置类上的注解少了一个参数

sqlSessionFactoryRef = "sqlSessionFactory1"

image.png

The bean 'sqlSessionFactory', defined in class path resource [com/mybatis/config/DBTwoConfig.class], could not be registered. A bean with that name has already been defined in class path resource [com/mybatis/config/DBOneConfig.class] and overriding is disabled.

image.png 这个问题的原因是两个配置类的方法是一样的,底层找不到对应的方法

image.png

image.png template的方法名也不能一样