Upd:更改数据源链接方式

master
duLingLing 5 years ago
parent 68042fe852
commit 536c691a20

@ -5,12 +5,12 @@
<parent>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>payment-parent</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -206,6 +206,13 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!-- HikariCP data Source-->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>

@ -1,6 +1,6 @@
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.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
@ -19,19 +19,17 @@ import java.util.Map;
@Configuration
@EnableTransactionManagement
public class DataSourceConfiguration {
@Value("${app.datasource.type:'com.alibaba.druid.pool.DruidDataSource'}")
private Class<? extends DataSource> dataSourceType;
@Bean(name = "masterDataSource")
@ConfigurationProperties(prefix = "app.datasource.master")
public DataSource masterDataSource() {
return DataSourceBuilder.create().type(dataSourceType).build();
return DataSourceBuilder.create().type(HikariDataSource.class).build();
}
@Bean(name = "slaveDataSource")
@ConfigurationProperties(prefix = "app.datasource.slave")
public DataSource slaveDataSource() {
return DataSourceBuilder.create().type(dataSourceType).build();
return DataSourceBuilder.create().type(HikariDataSource.class).build();
}

@ -13,7 +13,7 @@ public class ReadWriteSplitRoutingDataSource extends AbstractRoutingDataSource {
@Override
public Object determineCurrentLookupKey() {
DbContextHolder.DbType dataSource = DbContextHolder.getDbType();
logger.error("------------------当前数据源:{}---------------------",dataSource);
logger.info("------------------当前数据源:{}---------------------",dataSource);
return dataSource;
}

Loading…
Cancel
Save