|
|
@ -1,6 +1,6 @@
|
|
|
|
package au.com.royalpay.payment.manage.pos.datasource;
|
|
|
|
package au.com.royalpay.payment.manage.pos.datasource;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import com.zaxxer.hikari.HikariDataSource;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
@ -19,19 +19,17 @@ import java.util.Map;
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
@EnableTransactionManagement
|
|
|
|
@EnableTransactionManagement
|
|
|
|
public class DataSourceConfiguration {
|
|
|
|
public class DataSourceConfiguration {
|
|
|
|
@Value("${app.datasource.type:'com.alibaba.druid.pool.DruidDataSource'}")
|
|
|
|
|
|
|
|
private Class<? extends DataSource> dataSourceType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean(name = "masterDataSource")
|
|
|
|
@Bean(name = "masterDataSource")
|
|
|
|
@ConfigurationProperties(prefix = "app.datasource.master")
|
|
|
|
@ConfigurationProperties(prefix = "app.datasource.master")
|
|
|
|
public DataSource masterDataSource() {
|
|
|
|
public DataSource masterDataSource() {
|
|
|
|
return DataSourceBuilder.create().type(dataSourceType).build();
|
|
|
|
return DataSourceBuilder.create().type(HikariDataSource.class).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean(name = "slaveDataSource")
|
|
|
|
@Bean(name = "slaveDataSource")
|
|
|
|
@ConfigurationProperties(prefix = "app.datasource.slave")
|
|
|
|
@ConfigurationProperties(prefix = "app.datasource.slave")
|
|
|
|
public DataSource slaveDataSource() {
|
|
|
|
public DataSource slaveDataSource() {
|
|
|
|
return DataSourceBuilder.create().type(dataSourceType).build();
|
|
|
|
return DataSourceBuilder.create().type(HikariDataSource.class).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|