动态数据源
*/
@Bean("dynamicDataSource")
public javax.sql.DataSource dynamicDataSource() {
DynamicDataSource dynamicDataSource = new DynamicDataSource();
dynamicDataSource.setWriteDataSource(master());
List
/**
事务管理器配置
@return 返回事务管理器
*/
@Bean
public PlatformTransactionManager transactionManager() {
return new LecshopTransactionManager(dynamicDataSource());
}
seata版本 1.3.0 目前的框架是springclod的 但是做了数据库的读写分离配置如下: `
/**
主库 */ @Bean(name = "master", destroyMethod = "close", initMethod = "init") @Primary @ConfigurationProperties(prefix = "spring.datasource.druid.master") public javax.sql.DataSource master() { return DataSourceBuilder.create().type(DruidDataSource.class).build(); }
/**
从库 */ @Bean(name = "slave1") @ConfigurationProperties(prefix = "spring.datasource.druid.slave1") public javax.sql.DataSource slave1() { return DataSourceBuilder.create().type(DruidDataSource.class).build(); }
/**
动态数据源 */ @Bean("dynamicDataSource") public javax.sql.DataSource dynamicDataSource() { DynamicDataSource dynamicDataSource = new DynamicDataSource(); dynamicDataSource.setWriteDataSource(master()); List
/**
@return 返回事务管理器 */ @Bean public PlatformTransactionManager transactionManager() { return new LecshopTransactionManager(dynamicDataSource()); }
/**