jdbc集成phoneix hbase

为什么使用jdbc集成

  1. 需求简单,只是往phoneix存储数据
  2. 原本项目已经有mysql的mybatis plus集成,如果采用dataSource方式就需要采用多数据源的方式,造成架构复杂化,使用复杂化,并且修改地方过多。
@Qualifier("phoenixJdbcTemplate")
@Autowired
private JdbcTemplate jdbcTemplate;
@Configuration
public class PhoenixConfig {
    private String phoenixUrl;
    private String phoenixDriverClassName;
    @Bean(name = "phoenixJdbcTemplate")
    public JdbcTemplate phoenixJdbcTemplate() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setUrl(phoenixUrl);
        druidDataSource.setDriverClassName(phoenixDriverClassName);
        druidDataSource.setConnectionProperties("phoenix.schema.isNamespaceMappingEnabled=true");
        druidDataSource.setInitialSize(20);
        druidDataSource.setMaxActive(40);
        druidDataSource.setQueryTimeout(30);
        druidDataSource.setMaxWait(4000);
        druidDataSource.setDbType("phoenix");
        return new JdbcTemplate(druidDataSource);
    }
}

猜你喜欢

转载自blog.csdn.net/qq_44961149/article/details/132448389
今日推荐