package cn.huge.base.config;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
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 javax.sql.DataSource;
|
|
/**
|
* @title: 数据源配置
|
* @description: 数据源配置
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2021-11-05 16:51:48
|
* @version: 1.0.0
|
*/
|
@Configuration
|
public class DataSourceConfig {
|
|
@Primary
|
@Bean(name = "primaryDataSourceProperties")
|
@Qualifier("primaryDataSourceProperties")
|
@ConfigurationProperties(prefix = "spring.datasource")
|
public DataSourceProperties primaryDataSourceProperties() {
|
return new DataSourceProperties();
|
}
|
|
@Primary
|
@Bean(name = "primaryDataSource")
|
@Qualifier("primaryDataSource")
|
@ConfigurationProperties(prefix = "spring.datasource")
|
public DataSource primaryDataSource(@Qualifier("primaryDataSourceProperties") DataSourceProperties dataSourceProperties) {
|
return dataSourceProperties.initializeDataSourceBuilder().build();
|
}
|
|
}
|
/**
|
* -------------------_ooOoo_-------------------
|
* ------------------o8888888o------------------
|
* ------------------88" . "88------------------
|
* ------------------(| -_- |)------------------
|
* ------------------O\ = /O------------------
|
* ---------------____/`---'\____---------------
|
* -------------.' \\| |// `.-------------
|
* ------------/ \\||| : |||// \------------
|
* -----------/ _||||| -:- |||||- \-----------
|
* -----------| | \\\ - /// | |-----------
|
* -----------| \_| ''\---/'' | |-----------
|
* -----------\ .-\__ `-` ___/-. /-----------
|
* ---------___`. .' /--.--\ `. . __----------
|
* ------."" '< `.___\_<|>_/___.' >'"".-------
|
* -----| | : `- \`.;`\ _ /`;.`/ - ` : | |-----
|
* -----\ \ `-. \_ __\ /__ _/ .-` / /-----
|
* ======`-.____`-.___\_____/___.-`____.-'======
|
* -------------------`=---='
|
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
* ---------佛祖保佑---hugeinfo---永无BUG----------
|
*/
|