当前使用版本(必填,否则不予处理)

3.4.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

不同的数据源指定了同一个MybatisPlusProperties 理论上不应该啊,我的数据源明显指定了不同的,但是使用的时候却会sql语句会使用第一个数据源很奇怪

重现步骤(如果有就写完整)

@Configuration @MapperScan(basePackages = "com.xxx.mapper.xxxamapper", sqlSessionTemplateRef = "xxxdbSqlSessionTemplate") class XXXADBDataSource {

@Resource
private MybatisPlusProperties mybatisPlusProperties

@Bean(name = "xxxdbDataSource")
@ConfigurationProperties(prefix = "spring.datasource.druid.xxx")
DataSource dataSource() {
    DruidDataSource datasource = DruidDataSourceBuilder.create().build()
    return datasource
}

@Bean(name = "xxxdbSqlSessionFactory")
SqlSessionFactory sqlSessionFactory(@Qualifier("xxxdbDataSource") DataSource dataSource) throws Exception {
    MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean()
    bean.setConfiguration(mybatisPlusProperties.getConfiguration())
    bean.setMapperLocations(mybatisPlusProperties.resolveMapperLocations())
    bean.setDataSource(dataSource)
    return bean.getObject()
}

}

@Configuration @MapperScan(basePackages = "com.xxx.mapper.xxxbmapper", sqlSessionTemplateRef = "xxxbdbSqlSessionTemplate") class XXXBDBDataSource {

@Resource
private MybatisPlusProperties mybatisPlusProperties

@Bean(name = "xxxbdbDataSource")
@ConfigurationProperties(prefix = "spring.datasource.druid.xxxb")
DataSource dataSource() {
    DruidDataSource datasource = DruidDataSourceBuilder.create().build()
    return datasource
}

@Bean(name = "xxxbdbSqlSessionFactory")
SqlSessionFactory sqlSessionFactory(@Qualifier("xxxbdbDataSource") DataSource dataSource) throws Exception {
    MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean()
    bean.setConfiguration(mybatisPlusProperties.getConfiguration())
    bean.setMapperLocations(mybatisPlusProperties.resolveMapperLocations())
    bean.setDataSource(dataSource)
    return bean.getObject()
}

}

main: @EnableConfigurationProperties(MybatisPlusProperties.class)

报错信息

sql 数据库表找不到

Comment From: miemieYaho

mybatisPlusProperties.getConfiguration() 对象是同一个