Procházet zdrojové kódy

优化配置文件

欧阳劲驰 před 2 týdny
rodič
revize
c6903a637f

+ 1 - 1
custom-gateway-app/pom.xml

@@ -81,7 +81,7 @@
                 <configuration>
                     <skipTests>true</skipTests>
                     <systemPropertyVariables>
-                        <global.sql-config-path>../db_config.yml</global.sql-config-path>
+                        <spring.datasource.config-path>../db_config.yml</spring.datasource.config-path>
                         <device.map-path>../dev_map.yml</device.map-path>
                         <spring.datasource.multi.embedded.url>jdbc:h2:file:../data
                         </spring.datasource.multi.embedded.url>

+ 2 - 4
custom-gateway-app/src/main/resources/application-zydma.yml

@@ -1,8 +1,6 @@
-#第三方对接
+#对接
 calling:
-  connect-timeout: PT30S
-  read-timeout: PT30S
-  #对接信息
+  #对接点
   endpoints:
     middle-platform:
       url: http://223.75.194.87:8200/PandaCore/GCK

+ 9 - 7
custom-gateway-app/src/main/resources/application.yml

@@ -3,6 +3,10 @@ server:
   port: 9011
   servlet:
     context-path: /custom-gw/
+#网关
+gateway:
+  routes:
+    zydma: /zy-dma/
 #spring
 spring:
   application:
@@ -30,6 +34,7 @@ spring:
         size: 2
   #数据源
   datasource:
+    config-path: ./db_config.yml
     hikari:
       maximum-pool-size: 200
       minimum-idle: 1
@@ -52,13 +57,10 @@ security:
   permit-pattern:
     - /common/async-results
     - /common/temp-files
-#网关
-gateway:
-  routes:
-    zydma: /zy-dma/
-#全局
-global:
-  sql-config-path: ./db_config.yml
+#对接
+calling:
+  connect-timeout: PT30S
+  read-timeout: PT30S
 #异步
 async:
   result-path-pattern: /common/async-results

+ 1 - 1
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/config/DataSourceConfig.java

@@ -24,7 +24,7 @@ import static com.shkpr.service.customgateway.core.constants.DataSourceNames.PRI
  */
 @Configuration
 @EnableConfigurationProperties(DataSourceProperties.class)
-@PropertySource(value = "file:${global.sql-config-path}", ignoreResourceNotFound = true, encoding = "UTF-8", factory = YamlPropertySourceFactory.class)
+@PropertySource(value = "file:${spring.datasource.config-path}", ignoreResourceNotFound = true, encoding = "UTF-8", factory = YamlPropertySourceFactory.class)
 public class DataSourceConfig {
     /**
      * @param properties 属性

+ 1 - 1
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/config/InfluxDbConfig.java

@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
  */
 @Configuration
 @EnableConfigurationProperties(InfluxDbProperties.class)
-@PropertySource(value = "file:${global.sql-config-path}", ignoreResourceNotFound = true, encoding = "utf-8", factory = YamlPropertySourceFactory.class)
+@PropertySource(value = "file:${spring.datasource.config-path}", ignoreResourceNotFound = true, encoding = "utf-8", factory = YamlPropertySourceFactory.class)
 public class InfluxDbConfig {
     /**
      * influxDb注册器

+ 6 - 3
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/properties/DataSourceProperties.java

@@ -20,14 +20,17 @@ import java.util.Map;
 @ConfigurationProperties(prefix = "spring.datasource")
 public class DataSourceProperties {
     /**
-     * 数据源
+     * 配置文件路径
      */
-    private Map<String, DataSource> multi = new HashMap<>();
-
+    private String configPath;
     /**
      * hikari配置
      */
     private HikariConfig hikari;
+    /**
+     * 数据源
+     */
+    private Map<String, DataSource> multi = new HashMap<>();
 
     /**
      * 数据源