简体   繁体   English

从 spring 配置文件中删除其他配置文件

[英]Remove other profiles from spring configuration file

I have application.yaml configuration file with few profiles:我有包含几个配置文件的 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'

And I want to remove other profiles before build jar file.我想在构建 jar 文件之前删除其他配置文件。 I don't want to give access for prod_1's password to prod_2 platform for example.例如,我不想让 prod_1 的密码访问 prod_2 平台。

For prod_1 it must be something like this:对于 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'

or this:或这个:

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'

You can use multiple application-{profile}.yml and give each team the right file.您可以使用多个 application-{profile}.yml 并为每个团队提供正确的文件。

for example :例如 :

application-devArtem.yml ---> to team devArtem application-devArtem.yml ---> 到团队 devArtem
application-prod_1.yml ---> to team prod_1 application-prod_1.yml ---> 到团队 prod_1
application-prod_2.yml ---> to team prod_2 application-prod_2.yml ---> 到团队 prod_2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM