官术网_书友最值得收藏!

Multiple profiles inside a single YAML file

A YAML file can contain configuration for multiple profiles. You can define multiple profile-specific configurations in a single YAML file. Spring Boot provides a spring.profiles key to indicate when the document applies. Let's see the following example of how to define multiple profile-specific configurations in a single YAML file:

 
#Used for all profiles 
 
logging.level: 
org.springframework: INFO 
 
#'dev' profile only 
--- 
 
spring.profiles: dev 
database: 
   host: localhost 
   user: dev 
 
#'prod' profile only 
 
--- 
 
spring.profiles: prod 
database: 
   host: 192.168.200.109 
   user: admin 

In this application.yml file, we have defined database settings according to two profiles, dev and prod, by using a spring.profile key. In the file, '---' implies a separation between profiles.

Also, I've found that if you have both application.properties and application.yml side by side at the same level of precedence, properties in application.yml will override those in application.properties.

Let's see how to customize the error page in the Spring web application.

主站蜘蛛池模板: 洪泽县| 安陆市| 黄石市| 称多县| 若尔盖县| 聊城市| 灌阳县| 正镶白旗| 沅陵县| 哈尔滨市| 临江市| 芜湖市| 册亨县| 九寨沟县| 句容市| 青田县| 乌兰察布市| 常山县| 大兴区| 瑞安市| 长治市| 沅江市| 阜阳市| 徐州市| 威海市| 永川市| 扶风县| 沁源县| 岢岚县| 肇州县| 黎平县| 瑞金市| 肇东市| 余庆县| 白水县| 黄浦区| 施甸县| 韶关市| 新晃| 成都市| 剑川县|