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

  

上一篇:JDBCTemplate操作数据库


下一篇:JdbcTemplate简述