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

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.

主站蜘蛛池模板: 林口县| 哈尔滨市| 囊谦县| 如皋市| 扶沟县| 北安市| 双峰县| 棋牌| 沐川县| 临江市| 遂平县| 兴安县| 高安市| 清河县| 阜新市| 当涂县| 镇沅| 高州市| 思南县| 康平县| 修文县| 山阳县| 湖北省| 广灵县| 玉林市| 申扎县| 新化县| 青田县| 西昌市| 双江| 延边| 西贡区| 连南| 濮阳县| 民丰县| 东乡| 错那县| 甘孜| 清远市| 西吉县| 南郑县|