SZH
2022-06-25 9ceead016fb2caae838eab12e0ec394ab656326a
添加多数据源
已修改4个文件
63 ■■■■■ 文件已修改
safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
safePlatfrom-out-web/src/main/resources/config/application-dev.yaml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
safePlatfrom-out-web/src/main/resources/config/application-prod.yaml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
safePlatfrom-out-web/src/main/resources/config/application-test.yaml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
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
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
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