Java those things

Mybatis-plus 多数据源配置时失效

2020-07-01  本文已影响0人  M_ENG
@Bean
    public SqlSessionFactory sqlSessionFactoryRecordTdDb() throws Exception {
        SqlSessionFactoryBean factoryBean = newSqlSessionFactoryBean();
        factoryBean.setDataSource(recordTdDb);
        factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/record_td_db/*.xml"));
        return factoryBean.getObject();
    }

上面的 SqlSessionFactoryBean 替换成 MybatisSqlSessionFactoryBean

@Bean
    public SqlSessionFactory sqlSessionFactoryRecordTdDb() throws Exception {
        MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
        factoryBean.setDataSource(recordTdDb);
        factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/record_td_db/*.xml"));
        return factoryBean.getObject();
    }
上一篇下一篇

猜你喜欢

热点阅读