springboot+phoenix+mysql多数据源

2021/9/29 19:42:04

本文主要是介绍springboot+phoenix+mysql多数据源,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

@Configuration
public class PhoenixDataSource {

    @Bean(name = "phoenixDatasource")
    @ConfigurationProperties(prefix = "spring.phoenix.datasource")
    public DataSource phoenixDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "phoenixJdbcTemplate")
    public JdbcTemplate phoenixJdbcTemplate(@Qualifier("phoenixDatasource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    @Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource primaryDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean
    @Primary
    public JdbcTemplate jdbcTemplate(@Autowired DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}
spring.phoenix.datasource.jdbc-url=jdbc:phoenix:127.0.0.1:2181
spring.phoenix.datasource.driver-class-name=org.apache.phoenix.jdbc.PhoenixDriver
spring.phoenix.datasource.username=
spring.phoenix.datasource.password=
spring.phoenix.datasource.connection-properties=phoenix.schema.isNamespaceMappingEnabled=true

spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/db?characterEncoding=UTF-8 
spring.datasource.username=
spring.datasource.password=
spring.datasource.driverClassName: com.mysql.jdbc.Driver

  



这篇关于springboot+phoenix+mysql多数据源的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程