当前位置:网站首页>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);
}
}边栏推荐
- Jsp+mysql006 community management system
- SQL FOREIGN KEY
- SQL modification statement
- Boot 事务使用
- 【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
- 爱可可AI前沿推介(7.2)
- Postgressql stream replication active / standby switchover primary database no read / write downtime scenario
- 中科大脑知识图谱平台建设及业务实践
- 使用FFmpeg命令行进行UDP、RTP推流(H264、TS),ffplay接收
- The outline dimension function application of small motherboard
猜你喜欢

全是精华的模电专题复习资料:基本放大电路知识点

【Salesforce】如何确认你的Salesforce版本?

Ant group's large-scale map computing system tugraph passed the national evaluation

2020.4.12 byte written test questions B DP D monotone stack
![[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)

The sea of stars hidden behind the nebula graph

如何實現十億級離線 CSV 導入 Nebula Graph

动态规划入门二(5.647.62)

【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData

使用 percona 工具给 MySQL 表加字段中断后该如何操作
随机推荐
Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
Strings and arrays
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
Postgressql stream replication active / standby switchover primary database no read / write downtime scenario
解决** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau
Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
已知兩種遍曆序列構造二叉樹
Invalid bound statement (not found)解决方法总结
/bin/ld: 找不到 -lxslt
隐藏在 Nebula Graph 背后的星辰大海
The sea of stars hidden behind the nebula graph
Aiko ai Frontier promotion (7.2)
What are the necessary functions of short video app development?
Astra: could not open "2bc5/ [email protected] /6“: Failed to set USB interface
二叉树前,中,后序遍历
/Bin/ld: cannot find -lcrypto
如何实现十亿级离线 CSV 导入 Nebula Graph
处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin
【idea】推荐一个idea翻译插件:Translation「建议收藏」
/Bin/ld: cannot find -lxml2