package com.ywt.outpatient.config.db;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 * Created by huangguoping.
 */
@Configuration
public class Datasources {
    @Bean(name = "ywtCenterDataSource")
    @ConfigurationProperties(prefix="spring.datasource.ywtcenter")
    @Primary
    public DataSource ywtCenterDataSource(){
        return new HikariDataSource();
    }

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