From 9ceead016fb2caae838eab12e0ec394ab656326a Mon Sep 17 00:00:00 2001
From: SZH <szh_hello@163.com>
Date: 星期六, 25 六月 2022 16:25:22 +0800
Subject: [PATCH] 添加多数据源

---
 safePlatfrom-out-web/src/main/resources/config/application-prod.yaml                           |   12 +++---
 safePlatfrom-out-web/src/main/resources/config/application-dev.yaml                            |   14 +++---
 safePlatfrom-out-web/src/main/resources/config/application-test.yaml                           |   18 ++++----
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java |   19 ++++++++-
 4 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java
index df4e0b5..230546c 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java
@@ -13,14 +13,18 @@
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 import org.springframework.core.io.support.ResourcePatternResolver;
 import org.springframework.stereotype.Repository;
 
 import javax.sql.DataSource;
+import java.util.ArrayList;
+import java.util.Arrays;
 
 @Configuration
-@MapperScan(basePackages = "com.gkhy.safePlatform",sqlSessionTemplateRef = "sqlTemplate1",annotationClass =
+@MapperScan(basePackages = {"com.gkhy.safePlatform.emergency","com.gkhy.safePlatform.goalManage"},
+        sqlSessionTemplateRef = "sqlTemplate1",annotationClass =
         Repository.class)
 public class MyBatisConfigOne {
 
@@ -44,7 +48,18 @@
         MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
         factoryBean.setDataSource(dataSource);
         ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
-        factoryBean.setMapperLocations(resolver.getResources("classpath*:config/mapper/**/**Mapper.xml"));
+
+        //-------------------
+        Resource[] rs1 = resolver.getResources("classpath*:config/mapper/emergency/**Mapper.xml");
+        Resource[] rs2 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml");
+        ArrayList<Resource> resourceArrayList = new ArrayList<>(Arrays.asList(rs1));
+        resourceArrayList.addAll(new ArrayList<>(Arrays.asList(rs2)));
+        Resource[] resourceArray = new Resource[resourceArrayList.size()];
+        resourceArrayList.toArray(resourceArray);
+        factoryBean.setMapperLocations(resourceArray);
+        //-------------------
+
+//        factoryBean.setMapperLocations(resolver.getResources("classpath*:config/mapper/**/**Mapper.xml"));
         //设置分页插件
         Interceptor[] plugins = {mybatisPlusInterceptor};
         factoryBean.setPlugins(plugins);
diff --git a/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml b/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
index 643f67d..63cfbe7 100644
--- a/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
+++ b/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
@@ -11,7 +11,7 @@
   datasource:
     one:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://twt.sinanoaq.com:13306/zhongtai.demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.out.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
       username: root
       password: Sinanoaq#415
       type: com.alibaba.druid.pool.DruidDataSource
@@ -24,7 +24,7 @@
 dubbo:
   registry:
     protocol: nacos
-    address: nacos://192.168.0.62:18848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_safeplatform_out&password=9485uyJHISes09t
+    address: nacos://192.168.0.52:8848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_safeplatform_out&password=9485uyJHISes09t
   application:
     name: gkhy-safeplatform-account-provider
   scan:
@@ -41,13 +41,13 @@
     check: false
 
 minio:
-  endPoint: 192.168.0.62
+  endPoint: 192.168.0.52
   port: 9001
-  accessKey: kH6eiQtNrWqGNb1r
-  secretKey: ff5ykVUJJn0hi5PghsitdGNSsrW0Xrju
+  accessKey: MhLac53T2KD88fwD
+  secretKey: dGcLziFwyKaXuMcug385cfb6iGy61U8q
   secure: false
-  bucketName: szh-stu
-  urlPrefix: http://192.168.0.62/file
+  bucketName: safeplatform-dev
+  urlPrefix: http://192.168.0.52/file
 
 
 
diff --git a/safePlatfrom-out-web/src/main/resources/config/application-prod.yaml b/safePlatfrom-out-web/src/main/resources/config/application-prod.yaml
index 1fc34f4..d7474cc 100644
--- a/safePlatfrom-out-web/src/main/resources/config/application-prod.yaml
+++ b/safePlatfrom-out-web/src/main/resources/config/application-prod.yaml
@@ -24,7 +24,7 @@
 dubbo:
   registry:
     protocol: nacos
-    address: nacos://192.168.0.62:18848?namespace=71701971-5257-48d9-b745-a4218022b397&username=gkhy_safeplatform_out&password=9485uyJHISes09t
+    address: nacos://192.168.0.52:8848?namespace=71701971-5257-48d9-b745-a4218022b397&username=gkhy_safeplatform_out&password=9485uyJHISes09t
   application:
     name: gkhy-safeplatform-account-provider
   scan:
@@ -41,13 +41,13 @@
     check: false
 
 minio:
-  endPoint: 192.168.0.62
+  endPoint: 192.168.0.52
   port: 9001
-  accessKey: kH6eiQtNrWqGNb1r
-  secretKey: ff5ykVUJJn0hi5PghsitdGNSsrW0Xrju
+  accessKey: MhLac53T2KD88fwD
+  secretKey: dGcLziFwyKaXuMcug385cfb6iGy61U8q
   secure: false
-  bucketName: szh-stu
-  urlPrefix: http://192.168.0.62/file
+  bucketName: safeplatform-dev
+  urlPrefix: http://192.168.0.52/file
 
 
 
diff --git a/safePlatfrom-out-web/src/main/resources/config/application-test.yaml b/safePlatfrom-out-web/src/main/resources/config/application-test.yaml
index 780cb2d..5109dfa 100644
--- a/safePlatfrom-out-web/src/main/resources/config/application-test.yaml
+++ b/safePlatfrom-out-web/src/main/resources/config/application-test.yaml
@@ -11,9 +11,9 @@
   datasource:
     one:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://twt.sinanoaq.com:13306/zhongtai.demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
-      username: root
-      password: Sinanoaq#415
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.out.test?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+      username: gkhy_dev_out_team
+      password: Adsdf675T6AC7yga
       type: com.alibaba.druid.pool.DruidDataSource
 
 
@@ -24,7 +24,7 @@
 dubbo:
   registry:
     protocol: nacos
-    address: nacos://192.168.0.62:18848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_safeplatform_out&password=9485uyJHISes09t
+    address: nacos://192.168.0.52:8848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_safeplatform_out&password=9485uyJHISes09t
   application:
     name: gkhy-safeplatform-account-provider
   scan:
@@ -41,13 +41,13 @@
     check: false
 
 minio:
-  endPoint: 192.168.0.62
+  endPoint: 192.168.0.52
   port: 9001
-  accessKey: kH6eiQtNrWqGNb1r
-  secretKey: ff5ykVUJJn0hi5PghsitdGNSsrW0Xrju
+  accessKey: MhLac53T2KD88fwD
+  secretKey: dGcLziFwyKaXuMcug385cfb6iGy61U8q
   secure: false
-  bucketName: szh-stu
-  urlPrefix: http://192.168.0.62/file
+  bucketName: safeplatform-test
+  urlPrefix: http://192.168.0.52/file
 
 
 

--
Gitblit v1.9.2