-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
是否支持多数据源? #2
Comments
目前不支持,单纯通过自动配置来实现多数据源是不可行的,如果要添加多数据源功能势必要求用户手动声明 Bean,这似乎违背了 Starter 的初衷。不过我会提供一个多数据源的解决方案,争取下周发布。 |
1.0.2 版本已发布,新增多数据源支持,请参考 Druid 多数据源支持.md,druid-spring-boot-mybatis-example 中也有相应演示。 |
@drtrang 整合mybatis的时候,如何实现多数据源?(比如:selectOne()走的是mysql数据源, selectList走的aliyun的ads数据源)是需要手工配置mybatis的SqlSessionFactory吗?比如下面这样: @Bean(name = "masterSqlSessionFactory")
@Primary
public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource)
throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(masterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(MasterDataSourceConfig.MAPPER_LOCATION));
return sessionFactory.getObject();
} |
可以考虑Spring的AbstractRoutingDataSource,在调用方法时进行数据源切换 |
@drtrang 您给的demo访问404 |
代码结构改动较大,最新的地址如下。 |
谢谢
杨万宝
…_____________________________________________________
单位:四川长虹电器股份有限公司 软件与服务中心 云服务部
地址:四川绵阳市高新区绵兴东路35号
邮编:621000
手机: 18080260070
邮箱:wanbao.yang@changhong.com
原始邮件
发件人:Trangnotifications@github.com
收件人:drtrang/druid-spring-bootdruid-spring-boot@noreply.github.com
抄送:coolbaobeiwanbao.yang@changhong.com; Mentionmention@noreply.github.com
发送时间:2018年5月15日(周二) 15:36
主题:Re: [drtrang/druid-spring-boot] 是否支持多数据源? (#2)
@coolbaobei
代码结构改动较大,最新的地址如下。
多数据源原理:Druid 多数据源支持.md
Demo 演示:druid-spring-boot-mybatis-example
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
多数据源是否可以支持,示例上是否可以加上多数据的解决方案?
The text was updated successfully, but these errors were encountered: