当前位置:网站首页>多数据源配置代码
多数据源配置代码
2022-07-02 12:28: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);
//此处创建一个Configuration 注意包不要引错了
org.apache.ibatis.session.Configuration configuration=new org.apache.ibatis.session.Configuration();
//配置日志实现
configuration.setLogImpl(StdOutImpl.class);
//此处可以添加其他mybatis配置 例如转驼峰命名
configuration.setMapUnderscoreToCamelCase(true);
//bena工厂装载上面配置的Configuration
bean.setConfiguration(configuration);
//设置mapper配置文件
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(locations));
return bean.getObject();
}
/**创建SqlSessionTemplate*/
@Bean(name = "impalaSqlSessionTemplate")
public SqlSessionTemplate impalaSqlSessionTemplate(@Qualifier("impalaSqlSessionFactory") SqlSessionFactory sqlSessionFactory){
return new SqlSessionTemplate(sqlSessionFactory);
}
}边栏推荐
- [leetcode] 876 intermediate node of linked list
- 构建多架构镜像的最佳实践
- Introduction to dynamic planning I, BFS of queue (70.121.279.200)
- Name of institution approved in advance
- Pyinstaller's method of packaging pictures attached to exe
- Ssh/scp does not prompt all activities are monitored and reported
- PostgresSQL 流复制 主备切换 主库无读写宕机场景
- Thoroughly understand browser strong cache and negotiation cache
- 2279. 装满石头的背包的最大数量
- Solve the problem of base64encoder error
猜你喜欢

The outline dimension function application of small motherboard

Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)

已知两种遍历序列构造二叉树

蚂蚁集团大规模图计算系统TuGraph通过国家级评测

Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network

图数据库|Nebula Graph v3.1.0 性能报告
![[leetcode] 417 - Pacific Atlantic current problem](/img/30/c541bc1e81eb4e348ca11116a05e84.png)
[leetcode] 417 - Pacific Atlantic current problem

Pattern matching extraction of specific subgraphs in graphx graph Computing Practice

PHP static members

如何實現十億級離線 CSV 導入 Nebula Graph
随机推荐
蚂蚁集团大规模图计算系统TuGraph通过国家级评测
睿智的目标检测23——Pytorch搭建SSD目标检测平台
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit
The task cannot be submitted after the installation of flick is completed
使用 percona 工具给 MySQL 表加字段中断后该如何操作
2278. Percentage of letters in string
[leetcode] 486 predict winners
[leetcode] 1162 map analysis
如何实现十亿级离线 CSV 导入 Nebula Graph
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
ssh/scp 使不提示 All activities are monitored and reported.
Postgressql stream replication active / standby switchover primary database no read / write downtime scenario
[leetcode] 1140 stone game II
[leetcode] 695 - maximum area of the island
/Bin/ld: cannot find -lpam
Tree binary search tree
Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
PHP static members
Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
2279. Maximum number of backpacks filled with stones