美文网首页Java those things
Mybatis-plus 多数据源配置时失效

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

作者: M_ENG | 来源:发表于2020-07-01 16:13 被阅读0次
@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();
    }

相关文章

网友评论

    本文标题:Mybatis-plus 多数据源配置时失效

    本文链接:https://www.haomeiwen.com/subject/fechqktx.html