当前位置:网站首页>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);
}
}边栏推荐
- 【Salesforce】如何确认你的Salesforce版本?
- 《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
- 《大学“电路分析基础”课程实验合集.实验四》丨线性电路特性的研究
- 目标检测—利用labelimg制作自己的深度学习目标检测数据集
- Golang MD5 encryption and MD5 salt value encryption
- 愛可可AI前沿推介(7.2)
- PTA ladder game exercise set l2-001 inter city emergency rescue
- How to use percona tool to add fields to MySQL table after interruption
- /bin/ld: 找不到 -lxml2
- Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
猜你喜欢
![[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)](/img/26/3f19d36c048e669c736e27384e0fa7.jpg)
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)

又是一年毕业季

Deux séquences ergodiques connues pour construire des arbres binaires

Postgressql stream replication active / standby switchover primary database no read / write downtime scenario

Xpt2046 four wire resistive touch screen

《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究

Traversal before, during and after binary tree

Introduction to dynamic planning I, BFS of queue (70.121.279.200)

中科大脑知识图谱平台建设及业务实践

Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
随机推荐
Jsp+mysql006 community management system
Teach you how to build virtual machines locally and deploy microservices
Deux séquences ergodiques connues pour construire des arbres binaires
beforeEach
List of sergeant schools
ssh/scp 使不提示 All activities are monitored and reported.
(万字精华知识总结)Shell脚本编程基础知识
/bin/ld: 找不到 -lcrypto
隐藏在 Nebula Graph 背后的星辰大海
Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)
How to import a billion level offline CSV into Nepal graph
6091. Divide the array so that the maximum difference is K
多数据源配置代码
Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
matlab中wavedec2,说说wavedec2函数[通俗易懂]
中科大脑知识图谱平台建设及业务实践
win10系统升级一段时间后,内存占用过高
The task cannot be submitted after the installation of flick is completed
Demo of converting point cloud coordinates to world coordinates
idea 公共方法抽取快捷键