package com.holytax.accenture_fp_in.datasource;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
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;
/**
- 配置多数据源
-
-
-
*/@Configuration
br/>@Configuration
@Bean(name = "primaryDataSource")@Qualifier("primaryDataSource")
br/>@Qualifier("primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "secondaryDataSource")@Qualifier("secondaryDataSource")
br/>@Qualifier("secondaryDataSource")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
}
复制代码