当前位置:网站首页>多数据源配置代码
多数据源配置代码
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);
}
}边栏推荐
- beforeEach
- 【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
- [leetcode] 19 delete the penultimate node of the linked list
- PHP static members
- Aike AI frontier promotion (7.2)
- [leetcode] 1254 - count the number of closed Islands
- 已知兩種遍曆序列構造二叉樹
- 全方位解读服务网格(Service Mesh)的背景和概念
- [leetcode] 167 - sum of two numbers II - enter an ordered array
- 如何實現十億級離線 CSV 導入 Nebula Graph
猜你喜欢

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

动态规划入门一,队列的bfs(70.121.279.200)
![[leetcode] 1905 statistics sub Island](/img/82/d2f7b829f5beb7f9f1eabe8d101ecb.png)
[leetcode] 1905 statistics sub Island
![[leetcode] 1254 - count the number of closed Islands](/img/84/f888ae0e164951cd9623fb3bf4a984.png)
[leetcode] 1254 - count the number of closed Islands

二叉树前,中,后序遍历

The sea of stars hidden behind the nebula graph

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

隐藏在 Nebula Graph 背后的星辰大海

How to use percona tool to add fields to MySQL table after interruption

如何实现十亿级离线 CSV 导入 Nebula Graph
随机推荐
SQL FOREIGN KEY
/bin/ld: 找不到 -lxml2
制作p12证书[通俗易懂]
[salesforce] how to confirm your salesforce version?
基于 Nebula Graph 构建百亿关系知识图谱实践
locate: 无法执行 stat () `/var/lib/mlocate/mlocate.db‘: 没有那个文件或目录
【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
lseek 出错
Floyed "suggestions collection"
[leetcode] 695 - maximum area of the island
For the problem that Folium map cannot be displayed, the temporary solution is as follows
PostgresSQL 流复制 主备切换 主库无读写宕机场景
[leetcode] 1020 number of enclaves
Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
SQL修改语句
Ssh/scp does not prompt all activities are monitored and reported
已知兩種遍曆序列構造二叉樹
PHP static members
/bin/ld: 找不到 -lpam
[leetcode] 283 move zero