Home > Software engineering >  In what order are application.yml read in spring boot?
In what order are application.yml read in spring boot?

Time:09-30

I suppose that it reads in work working contour and then it reads in testing contour.

If application.yml is in testing contour , it settings replace the settings has been reading in application.yml of working contour. If You have defined application-test.yml and you point above a class an annotation @SpringBootTest and above @ActiveProfile("test") then the settings from application-test.yml replaces earlier settings.

what do you think about all this ? How to understand this process correctly?

CodePudding user response:

you have to put this in your application-test.yml

spring:
  profiles: test

CodePudding user response:

According to Spring Boot reference documentation, the configuration data files are considered in the following order:

  1. Application properties packaged inside your jar (application.properties and YAML variants).
  2. Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
  3. Application properties outside of your packaged jar (application.properties and YAML variants).
  4. Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).
  • Related