[英]Remove other profiles from spring configuration file
我有包含幾個配置文件的 application.yaml 配置文件:
server:
address: 0.0.0.0
port: 9090
db:
url: 'jdbc:postgresql://localhost:5432/the_db'
driver: 'org.postgresql.Driver'
username: 'postgres'
password: ''
---
spring:
profiles: devArtem
db:
url: 'jdbc:postgresql://localhost:5432/my_db'
---
spring:
profiles: prod_1
db:
password: 'first_pass'
---
spring:
profiles: prod_2
db:
password: 'second_pass'
我想在構建 jar 文件之前刪除其他配置文件。 例如,我不想讓 prod_1 的密碼訪問 prod_2 平台。
對於 prod_1,它必須是這樣的:
server:
address: 0.0.0.0
port: 9090
db:
url: 'jdbc:postgresql://localhost:5432/the_db'
driver: 'org.postgresql.Driver'
username: 'postgres'
password: 'first_pass'
或這個:
server:
address: 0.0.0.0
port: 9090
db:
url: 'jdbc:postgresql://localhost:5432/the_db'
driver: 'org.postgresql.Driver'
username: 'postgres'
password: ''
---
spring:
profiles: prod_1
db:
password: 'first_pass'
您可以使用多個 application-{profile}.yml 並為每個團隊提供正確的文件。
例如 :
application-devArtem.yml ---> 到團隊 devArtem
application-prod_1.yml ---> 到團隊 prod_1
application-prod_2.yml ---> 到團隊 prod_2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.