当前位置:网站首页>Multi data source configuration code
Multi data source configuration code
2022-07-02 15:54:00 【lvhui321】
@Configuration
public class ImpalaDataSourceConfig {
@Value("${impala.drive_class_name}")
private String driverClassName;
@Value("${impala.jdbc_url}")
private String jdbcUrl;
@Value("${impala.mapper-locations}")
private String locations;
@Bean(name = "impalaDataSource")
@Qualifier(value = "impalaDataSource")
public DataSource primaryDataSource() {
HikariConfig config = new HikariConfig();
config.setDriverClassName(driverClassName);
config.setJdbcUrl(jdbcUrl);
HikariDataSource dataSource = new HikariDataSource(config);
return dataSource;
}
@Bean(name = "impalaSqlSessionFactory")
public SqlSessionFactory impalaSqlSessionFactory(@Qualifier("impalaDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
// Create one here Configuration Be careful not to mislead the bag
org.apache.ibatis.session.Configuration configuration=new org.apache.ibatis.session.Configuration();
// Configure log implementation
configuration.setLogImpl(StdOutImpl.class);
// You can add others here mybatis To configure For example, hump naming
configuration.setMapUnderscoreToCamelCase(true);
//bena The factory loads the above configured Configuration
bean.setConfiguration(configuration);
// Set up mapper The configuration file
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(locations));
return bean.getObject();
}
/** establish SqlSessionTemplate*/
@Bean(name = "impalaSqlSessionTemplate")
public SqlSessionTemplate impalaSqlSessionTemplate(@Qualifier("impalaSqlSessionFactory") SqlSessionFactory sqlSessionFactory){
return new SqlSessionTemplate(sqlSessionFactory);
}
}
边栏推荐
- Tree binary search tree
- College entrance examination admission score line crawler
- Introduction to dynamic planning I, BFS of queue (70.121.279.200)
- 已知兩種遍曆序列構造二叉樹
- Group by的用法
- 2303. Calculate the total tax payable
- The outline dimension function application of small motherboard
- 数仓中的维度表与事实表
- 6090. 极大极小游戏
- 将点云坐标转换成世界坐标的demo
猜你喜欢
解决** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
如何實現十億級離線 CSV 導入 Nebula Graph
Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit
Tree binary search tree
动态规划入门二(5.647.62)
Armv8-a programming guide MMU (4)
Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
PTA ladder game exercise set l2-001 inter city emergency rescue
随机推荐
Fiddler realizes mobile packet capturing - getting started
Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
树-二叉搜索树
全是精华的模电专题复习资料:基本放大电路知识点
Why does the system convert the temp environment variable to a short file name?
Moveit 避障路径规划 demo
Jsp+mysql006 community management system
处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin
6092. Replace elements in the array
制作p12证书[通俗易懂]
6090. 极大极小游戏
Some problems about pytorch extension
6095. Strong password checker II
《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量
floyed「建议收藏」
/bin/ld: 找不到 -lgssapi_krb5
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit
智联招聘的基于 Nebula Graph 的推荐实践分享
/bin/ld: 找不到 -lcrypto
The task cannot be submitted after the installation of flick is completed