mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
feat: 添加多数据源切换支持 Service 实现类。
This commit is contained in:
parent
fd8fe4fa20
commit
f5b78643b3
@ -17,6 +17,8 @@ package com.mybatisflex.spring.boot;
|
|||||||
|
|
||||||
import com.mybatisflex.core.datasource.DataSourceBuilder;
|
import com.mybatisflex.core.datasource.DataSourceBuilder;
|
||||||
import com.mybatisflex.core.datasource.FlexDataSource;
|
import com.mybatisflex.core.datasource.FlexDataSource;
|
||||||
|
import com.mybatisflex.spring.datasource.DataSourceAdvice;
|
||||||
|
import com.mybatisflex.spring.datasource.DataSourceInterceptor;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
@ -69,5 +71,10 @@ public class MultiDataSourceAutoConfiguration {
|
|||||||
return flexDataSource;
|
return flexDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public DataSourceAdvice dataSourceAdvice() {
|
||||||
|
return new DataSourceAdvice(new DataSourceInterceptor());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user