[英]How to use spring cloud config server with postgresql and jdbc as backend with multiple profiles?
我只能使用带有 bootstrap.yml 文件的 spring 云配置服务器连接到 postgres。
但我有多个环境,如开发、测试和生产。 所以我想为每个环境创建单独的配置文件(如 bootstap-dev.properties)并相应地更改 url 数据源 url。
有人可以建议我吗?
引导程序.yml:
server:
port: 8081
spring:
application:
name: myapp
profiles:
active: jdbc
datasource:
url: jdbc:postgresql://localhost:5432/config_db
username: XXXX
password: XXXX
driverClassName: org.postgresql.Driver
cloud:
config:
server:
jdbc:
sql: SELECT key, value FROM properties WHERE application=? AND profile=? AND label=?;
order: 0
default-label: default
bus:
trace:
enabled: true
security:
user:
name: XXX
password: XXX
management:
endpoints:
web:
exposure:
include: bus-refresh,health
endpoint:
health:
show-details: always
在spring cloud中很容易使用。 首先,创建一个内容只遵循的spring.profiles.active=dev
其次,将您的开发应用程序.properties 名称修改为 application-dev.properties。 好的,然后把它们一起放到你的资源目录中。
其他的,你可以再创建一个不同后缀的环境文件,比如application-test.properties
或者application-pro.properties
...,并且只将active值改成后缀名即可。 像这样spring.profiles.active=test
我对你最好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.