配置文件添加读取环境变量的支持:

作用:
1.通过加持环境变量让运行更加灵活;
2.支持Docker官方的Docker Swarm多主机的集群支持;
说明:
defaultZone: http://pig:pig@${EUREKA-HOST:pigx-eureka}:${EUREKA-PORT:8761}/eureka/
如果配置了大括号里面的冒号前面的环境变量则使用,否则使用冒号后面的默认值.
This commit is contained in:
dbdu committed 2019-04-03 16:15:55 +08:00
1 parent 56a2f1ebdf
commit b024fe5695
21 files changed
+42 -42

No files matched your search

+1 -1
View File
@@ -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
View File
@@ -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:
@@ -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
@@ -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,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
@@ -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/
@@ -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:
@@ -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
@@ -8,5 +8,5 @@ ignore:
clients:
- test
swagger-providers:
- pigx-auth
- pigx-tx-manager
- ${AUTH-HOST:pigx-auth}
- ${TX-MGR-HOST:pigx-tx-manager}
@@ -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,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:
@@ -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/
@@ -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/
@@ -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/
@@ -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/
@@ -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/
@@ -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/
@@ -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")
@@ -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/
@@ -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/
@@ -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/