当前位置:网站首页>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);
}
}边栏推荐
- 6092. Replace elements in the array
- 6090. 极大极小游戏
- 多数据源配置代码
- 2303. Calculate the total tax payable
- SQL modification statement
- Aiko ai Frontier promotion (7.2)
- 【Salesforce】如何确认你的Salesforce版本?
- 目标检测—利用labelimg制作自己的深度学习目标检测数据集
- Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
- beforeEach
猜你喜欢

2020.4.12 byte written test questions B DP D monotone stack

Thoroughly understand browser strong cache and negotiation cache

《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量

Application of visualization technology in Nebula graph

Introduction to Dynamic Planning II (5.647.62)

Aiko ai Frontier promotion (7.2)

The sea of stars hidden behind the nebula graph

Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit

Boot 事务使用
![[leetcode] 417 - Pacific Atlantic current problem](/img/30/c541bc1e81eb4e348ca11116a05e84.png)
[leetcode] 417 - Pacific Atlantic current problem
随机推荐
如何實現十億級離線 CSV 導入 Nebula Graph
全方位解读服务网格(Service Mesh)的背景和概念
What are the necessary functions of short video app development?
idea jar包冲突排查
lseek 出错
Add an empty column to spark dataframe - add an empty column to spark dataframe
[idea] recommend an idea translation plug-in: translation "suggestions collection"
PostgresSQL 流复制 主备切换 主库无读写宕机场景
List of sergeant schools
Why does the system convert the temp environment variable to a short file name?
/bin/ld: 找不到 -lcrypto
How to import a billion level offline CSV into Nepal graph
Fiddler realizes mobile packet capturing - getting started
Application of visualization technology in Nebula graph
数仓中的维度表与事实表
2279. Maximum number of backpacks filled with stones
/bin/ld: 找不到 -lgssapi_krb5
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
College entrance examination admission score line crawler
Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network