Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring boot - application yml for each developer

Tags:

spring-boot

In my work the fields in application.yml are dynamics and each developer have another (dynamic) configuration. So, we have the general yml section, that relevant for all of us (and have updates from time to time) and the “private profile”

Like this:

spring:
  profiles: default
  configuration:
    ...
    ...

spring:
  profiles: development1
configuration: ...

spring:
  profiles: development2
configuration: ...

We have “small” problems with this (mistakes, conflicts, etc.) and we’re look for solution. I think about separate yml file for each developer, such as:

spring:
  profiles: development1
configuration:
  yml-file: app_dev1.yml

spring:
  profiles: development2
configuration:
  yml-file: app_dev2.yml

but didn’t find how to do this…

Will be glad to know if it can be done? (or you have another way to separate the yml between us).

We do not want to set an application yaml with annotation (git issues again..), something like Environment Variables...

like image 642
AsfK Avatar asked Mar 05 '20 10:03

AsfK


People also ask

Can we use application yml in spring boot?

As well as Java properties files, we can also use YAML-based configuration files in our Spring Boot application. YAML is a convenient format for specifying hierarchical configuration data. This can be more readable than its property file alternative since it does not contain repeated prefixes.

Can we have multiple application properties in spring boot?

Spring Boot supports different properties based on the Spring active profile. For example, we can keep two separate files for development and production to run the Spring Boot application.


1 Answers

Spring boot by default loads application.yaml but in addition if you run with --spring.profiles.active=dev1 it will load file application-dev1.yaml

So you could create yaml file per developer + have some "common" configuration in application.yaml

With such an approach you won't need lines like:

spring:
  profiles: dev1

... in any of the yaml files

like image 55
Mark Bramnik Avatar answered Nov 07 '22 09:11

Mark Bramnik