diff --git a/ktg-admin/pom.xml b/ktg-admin/pom.xml
index dbebbe6..2ec34a2 100644
--- a/ktg-admin/pom.xml
+++ b/ktg-admin/pom.xml
@@ -103,32 +103,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
com.dm
DmJdbcDriver
@@ -139,7 +113,12 @@
hibernate5
5.4
-
+
+
+ com.microsoft.sqlserver
+ mssql-jdbc
+ 12.2.0.jre8
+
diff --git a/ktg-admin/src/main/resources/application-druid.yml b/ktg-admin/src/main/resources/application-druid.yml
index ac71691..7eec95a 100644
--- a/ktg-admin/src/main/resources/application-druid.yml
+++ b/ktg-admin/src/main/resources/application-druid.yml
@@ -2,22 +2,23 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
- driverClassName: dm.jdbc.driver.DmDriver
druid:
# 主库数据源
- master:
+ dm:
+ driverClassName: dm.jdbc.driver.DmDriver
# url: jdbc:dm://30.30.2.24:5237/WMS_DJ?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-# url: jdbc:dm://localhost:5236/WMS_DJ?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+ # url: jdbc:dm://localhost:5236/WMS_DJ?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:dm://192.168.8.60:5236/WMS_DJ?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: SYSDBA
password: SYSDBA
# 从库数据源
- slave:
+ sqlserver:
# 从数据源开关/默认关闭
- enabled: false
- url:
- username:
- password:
+ enabled: true
+ driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
+ url: jdbc:sqlserver://192.168.8.60:5236:1433;DatabaseName=DPG_RH_YQ_20240711
+ username: sa
+ password: rh123456
# 初始连接数
initialSize: 5
# 最小连接池数量
diff --git a/ktg-admin/src/main/resources/application.yml b/ktg-admin/src/main/resources/application.yml
index cc555d4..736ed7c 100644
--- a/ktg-admin/src/main/resources/application.yml
+++ b/ktg-admin/src/main/resources/application.yml
@@ -63,15 +63,13 @@ spring:
# redis 配置
redis:
# 地址
-# host: 192.168.8.60
- host: 127.0.0.1
+ host: 192.168.8.60
# 端口,默认为6379
port: 6379
# 数据库索引
database: 4
# 密码
-# password: 123456
- password:
+ password: 123456
# 连接超时时间
timeout: 10s
lettuce:
diff --git a/ktg-admin/src/main/resources/logback.xml b/ktg-admin/src/main/resources/logback.xml
index fbedcc3..5a8fa21 100644
--- a/ktg-admin/src/main/resources/logback.xml
+++ b/ktg-admin/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/ktg-common/src/main/java/com/ktg/common/annotation/DataSource.java b/ktg-common/src/main/java/com/ktg/common/annotation/DataSource.java
index a2a5b09..bd56b9f 100644
--- a/ktg-common/src/main/java/com/ktg/common/annotation/DataSource.java
+++ b/ktg-common/src/main/java/com/ktg/common/annotation/DataSource.java
@@ -24,5 +24,5 @@ public @interface DataSource
/**
* 切换数据源名称
*/
- public DataSourceType value() default DataSourceType.MASTER;
+ public DataSourceType value() default DataSourceType.DM;
}
diff --git a/ktg-common/src/main/java/com/ktg/common/enums/DataSourceType.java b/ktg-common/src/main/java/com/ktg/common/enums/DataSourceType.java
index ef3089e..762de84 100644
--- a/ktg-common/src/main/java/com/ktg/common/enums/DataSourceType.java
+++ b/ktg-common/src/main/java/com/ktg/common/enums/DataSourceType.java
@@ -10,10 +10,10 @@ public enum DataSourceType
/**
* 主库
*/
- MASTER,
+ DM,
/**
* 从库
*/
- SLAVE
+ SQLSERVER,
}
diff --git a/ktg-framework/src/main/java/com/ktg/framework/config/DruidConfig.java b/ktg-framework/src/main/java/com/ktg/framework/config/DruidConfig.java
index 7e79ffb..fc5705c 100644
--- a/ktg-framework/src/main/java/com/ktg/framework/config/DruidConfig.java
+++ b/ktg-framework/src/main/java/com/ktg/framework/config/DruidConfig.java
@@ -9,6 +9,8 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -33,17 +35,17 @@ import com.ktg.framework.datasource.DynamicDataSource;
public class DruidConfig
{
@Bean
- @ConfigurationProperties("spring.datasource.druid.master")
- public DataSource masterDataSource(DruidProperties druidProperties)
+ @ConfigurationProperties("spring.datasource.druid.dm")
+ public DataSource dmDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean
- @ConfigurationProperties("spring.datasource.druid.slave")
- @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
- public DataSource slaveDataSource(DruidProperties druidProperties)
+ @ConfigurationProperties("spring.datasource.druid.sqlserver")
+ @ConditionalOnProperty(prefix = "spring.datasource.druid.sqlserver", name = "enabled", havingValue = "true")
+ public DataSource sqlServerDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
@@ -51,12 +53,20 @@ public class DruidConfig
@Bean(name = "dynamicDataSource")
@Primary
- public DynamicDataSource dataSource(DataSource masterDataSource)
- {
+ public DynamicDataSource dataSource(@Qualifier("dmDataSource") DataSource dmDataSource) {
Map