Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use multiple yaml files in a single spring boot application?

I have one yaml file that reads all the environment profiles. I need another yaml file to create a feature switch that i can turn on/off during deployment. And how can we define the feature switch in properties file.

like image 357
Aaron Avatar asked Dec 05 '22 13:12

Aaron


2 Answers

Yes, you can use multiple YAML files if you use spring profile. For example, if you start your JVM with the following flag:

-Dspring.profiles.active=deployed,cassandra

It will pick up the following application YAML files:

application.yml, application-deployed.yml, and application-cassandra.yml

like image 94
Indra Basak Avatar answered Mar 22 '23 22:03

Indra Basak


Another way to do this, is by adding this key in the application.yml file like below

spring:
  profiles:
    include:
      - student
      - address

and you can name your yaml files, as

application-student.yml, application-address.yml
like image 25
GopiKrishhna Chokkalamani Avatar answered Mar 22 '23 22:03

GopiKrishhna Chokkalamani