Spring Boot 集成MyBatis 访问Hbase-Phoenix
来源:互联网 发布:2017日本进出口数据 编辑:程序博客网 时间:2024/05/22 15:35
第一步:引入需要的maven
<dependency><groupId>org.apache.phoenix</groupId><artifactId>phoenix-core</artifactId><version>4.13.0-HBase-1.3</version></dependency><dependency><groupId>io.netty</groupId><artifactId>netty-all</artifactId><version>4.0.4.Final</version></dependency>
第二步:配置spring boot的数据源
package com.kevin.config;import com.alibaba.druid.pool.DruidDataSource;import org.apache.ibatis.session.SqlSessionFactory;import org.mybatis.spring.SqlSessionFactoryBean;import org.mybatis.spring.annotation.MapperScan;import org.springframework.beans.factory.annotation.Qualifier;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.context.annotation.Primary;import org.springframework.context.annotation.PropertySource;import org.springframework.core.io.support.PathMatchingResourcePatternResolver;import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;/** *@Aurhor kevin liu *@CreateDate 2017-11-22 16:25 *@描述: hbase-phoenix 数据源模版 */@Configuration@PropertySource(value="classpath:application.properties")@MapperScan(basePackages = HbasePhoenixDataSourceConfig.PACKAGE,sqlSessionFactoryRef = HbasePhoenixDataSourceConfig.HBASEPHOENIX_SQL_SESSION_FACTORY)public class HbasePhoenixDataSourceConfig { static final String HBASEPHOENIX_SQL_SESSION_FACTORY = "hbasePhoenixSqlSessionFactory"; static final String PACKAGE = "com.kevin.dao.hbase"; static final String MAPPER_LOCATION = "classpath:mapper/hbase/*.xml"; @Value("${hbase.phoenix.datasource.url}") private String url; @Value("${hbase.phoenix.datasource.driverClassNam}") private String driverClass; @Bean(name = "hbasePhoenixDataSource") public DataSource hbasePhoenixDataSource() { DruidDataSource dataSource = new DruidDataSource(); dataSource.setDriverClassName(driverClass); dataSource.setUrl(url); return dataSource; } @Bean(name = "hbasePhoenixTransactionManager") public DataSourceTransactionManager hbasePhoenixTransactionManager(@Qualifier("hbasePhoenixDataSource") DataSource dataSource) { return new DataSourceTransactionManager(dataSource); } @Bean(name = HBASEPHOENIX_SQL_SESSION_FACTORY) public SqlSessionFactory hbasePhoenixSqlSessionFactory(@Qualifier("hbasePhoenixDataSource") DataSource hbasePhoenixDataSource) throws Exception { final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(hbasePhoenixDataSource); sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver() .getResources(HbasePhoenixDataSourceConfig.MAPPER_LOCATION)); return sessionFactory.getObject(); }}
阅读全文
0 0
- Spring Boot 集成MyBatis 访问Hbase-Phoenix
- Spring Boot集成MyBatis访问数据库
- Spring Boot 集成MyBatis
- Spring Boot 集成Mybatis
- spring-boot集成mybatis
- Spring boot集成Mybatis
- Spring Boot 集成MyBatis
- spring boot集成mybatis
- Spring Boot集成MyBatis
- Spring Boot 集成MyBatis
- Spring Boot 集成MyBatis
- Spring Boot 集成MyBatis
- Spring Boot 集成MyBatis
- Spring Boot集成mybatis
- Spring Boot集成Mybatis
- spring boot 集成mybatis
- Spring Boot 集成MyBatis
- Spring Boot集成Mybatis
- 第八章、安装软件程序
- iOS 11开发教程(十四)iOS11应用代码添加视图
- 发票校验后台表
- 视图的隐藏显示附加Gilde加载图片模版
- 京东二级购物车
- Spring Boot 集成MyBatis 访问Hbase-Phoenix
- Java基础学习笔记16——(List的子类,泛型类,增强for循环,静态导入,可变参数)
- HDFS_数据迁移&节点迁移
- Hadoop(1)入门
- linux下elasticsearch 安装、配置及示例
- libevent写httpserver
- cache结构与工作原理
- 基于云上分布式NoSQL的海量气象数据存储和查询方案
- [转]【OpenCV入门教程之十】 形态学图像处理(一):膨胀与腐蚀