Applications generally will be installed in several different environments (such as development, testing, production, etc.), each environment will have some parameters are not the same.
Spring Boot have also provided support, as long as the name of the configuration file application-{profile}.yaml
format to which {profile}
a corresponding identification of the environment:
-
application-dev.yaml
: Development Environment -
application-test.yaml
: test environment -
application-prod.yaml
: Production Environment
Thereafter, necessary to application.yaml
set the configuration attribute spring.profiles.active
, whose value corresponds to {profile}
value.
Such as: spring.profile.active: dev
In this case it will be loaded application.yaml
and the application-dev.yaml
contents of the two profiles, two files if the same attribute, use can application-dev.yaml
values.
However, if you do not set spring.profiles.active, or use the application.yaml configuration!
Reference Links: https://www.jianshu.com/p/21f9541e17d9