[英]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.