Bläddra i källkod

配置文件添加读取环境变量的支持:
作用:
1.通过加持环境变量让运行更加灵活;
2.支持Docker官方的Docker Swarm多主机的集群支持;
说明:
defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
如果配置了大括号里面的冒号前面的环境变量则使用,否则使用冒号后面的默认值.

dbdu 6 år sedan
förälder
incheckning
b024fe5695

+ 1 - 1
pigx-auth/src/main/resources/bootstrap.yml

@@ -21,4 +21,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/

+ 1 - 1
pigx-config/src/main/resources/bootstrap.yml

@@ -19,7 +19,7 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
 
 # 暴露监控端点
 management:

+ 5 - 5
pigx-config/src/main/resources/config/application-dev.yml

@@ -6,11 +6,11 @@ jasypt:
 spring:
   redis:
     password:
-    host: pigx-redis
+    host: ${REDIS-HOST:pigx-redis}
   # zipkin
   zipkin:
     enabled: true
-    base-url: http://pigx-zipkin
+    base-url: http://${ZIPKIN-HOST:pigx-zipkin}
   sleuth:
     web:
       client:
@@ -79,7 +79,7 @@ mybatis-plus:
 
 #swagger公共信息
 swagger:
-  host: pigx-gateway:9999
+  host: ${GATEWAY-HOST:pigx-gateway}:${GATEWAY-PORT:9999}
   title: PigX Swagger API
   description: 全宇宙最牛逼的Spring Cloud微服务开发脚手架
   version: @project.version@
@@ -97,7 +97,7 @@ swagger:
       - scope: server
         description: server all
     token-url-list:
-      - http://pigx-gateway:9999/auth/oauth/token
+      - http://${GATEWAY-HOST:pigx-gateway}:${GATEWAY-PORT:9999}/auth/oauth/token
 
 ## spring security 配置
 security:
@@ -109,4 +109,4 @@ security:
         - /v2/api-docs
     resource:
       loadBalanced: true
-      token-info-uri: http://pigx-auth/oauth/check_token
+      token-info-uri: http://${AUTH-HOST:pigx-auth}/oauth/check_token

+ 3 - 3
pigx-config/src/main/resources/config/pigx-activiti-dev.yml

@@ -22,9 +22,9 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx_ac?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_ac}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
 
 # 租户表维护
 pigx:

+ 3 - 3
pigx-config/src/main/resources/config/pigx-auth-dev.yml

@@ -3,9 +3,9 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
   freemarker:
     allow-request-override: false
     allow-session-override: false

+ 3 - 3
pigx-config/src/main/resources/config/pigx-codegen-dev.yml

@@ -10,8 +10,8 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
   resources:
     static-locations: classpath:/static/,classpath:/views/

+ 4 - 4
pigx-config/src/main/resources/config/pigx-daemon-elastic-job-dev.yml

@@ -11,13 +11,13 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
   elasticjob:
     # 分布式任务协调依赖zookeeper
     zookeeper:
-      server-lists: pigx-zookeeper:2181
+      server-lists: ${ZOOKEEPER-HOST:pigx-zookeeper}:${ZOOKEEPER-PORT:2181}
       namespace: pigx-daemon
     # 普通任务
     simples:

+ 4 - 4
pigx-config/src/main/resources/config/pigx-daemon-quartz-dev.yml

@@ -16,9 +16,9 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
   resources:
     static-locations: classpath:/static/,classpath:/views/
   quartz:
@@ -43,7 +43,7 @@ spring:
             threadsInheritContextClassLoaderOfInitializingThread: true
     #数据库方式
     job-store-type: jdbc
-      #初始化表结构
+    #初始化表结构
     #jdbc:
     #initialize-schema: never
 

+ 2 - 2
pigx-config/src/main/resources/config/pigx-gateway-dev.yml

@@ -8,5 +8,5 @@ ignore:
   clients:
     - test
   swagger-providers:
-    - pigx-auth
-    - pigx-tx-manager
+    - ${AUTH-HOST:pigx-auth}
+    - ${TX-MGR-HOST:pigx-tx-manager}

+ 3 - 3
pigx-config/src/main/resources/config/pigx-upms-biz-dev.yml

@@ -19,9 +19,9 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true
 
 # 文件系统 (提供测试环境,不要乱传)
 minio:

+ 3 - 3
pigx-config/src/main/resources/config/pigx-zipkin-dev.yml

@@ -3,9 +3,9 @@ spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    username: root
-    password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx_zipkin?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
+    username: ${MYSQL-USER:root}
+    password: ${MYSQL-PWD:root}
+    url: jdbc:mysql://${MYSQL-HOST:pigx-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pigxx_zipkin}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
 management:
   metrics:
     web:

+ 1 - 1
pigx-gateway/src/main/resources/bootstrap.yml

@@ -22,6 +22,6 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
 
 

+ 1 - 1
pigx-upms/pigx-upms-biz/src/main/resources/bootstrap.yml

@@ -23,4 +23,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/

+ 1 - 1
pigx-visual/pigx-activiti/src/main/resources/bootstrap.yml

@@ -22,5 +22,5 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
 

+ 1 - 1
pigx-visual/pigx-codegen/src/main/resources/bootstrap.yml

@@ -22,4 +22,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/

+ 1 - 1
pigx-visual/pigx-daemon-elastic-job/src/main/resources/bootstrap.yml

@@ -22,4 +22,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/

+ 1 - 1
pigx-visual/pigx-daemon-quartz/src/main/resources/bootstrap.yml

@@ -25,4 +25,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/

+ 1 - 1
pigx-visual/pigx-monitor/src/main/resources/bootstrap.yml

@@ -22,7 +22,7 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
 turbine:
   app-config: pigx-upms,pigx-auth
   cluster-name-expression: new String("default")

+ 1 - 1
pigx-visual/pigx-sso-client-demo/src/main/resources/bootstrap.yml

@@ -24,4 +24,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/

+ 1 - 1
pigx-visual/pigx-tx-manager/src/main/resources/bootstrap.yml

@@ -22,5 +22,5 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
 

+ 1 - 1
pigx-visual/pigx-zipkin/src/main/resources/bootstrap.yml

@@ -22,4 +22,4 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://pig:pig@pigx-eureka:8761/eureka/
+      defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/