SpringBoot_application.yaml配置

yaml语法

  • 普通的key-value, name: yang

  • 对象 student:

  • 数组 pets: [cat,dog]

  • 可以注入到配置类中
    - 使用yaml注入对象。在对象类上添加@ConfigurationProperties(prefix = "xxx")注解。如果不进行配置,但使用了上述注解就会爆红,但是不影响程序运行。
    - yaml中可以使用el表达式。
    - 使用@Validated来开启数据校验。使用JSR-303校验。

  • SpringBoot配置多环境
    - 使用 “---” 将多个环境分开

posted @ 2020-05-21 08:53  yangzixiongh  阅读(373)  评论(0编辑  收藏  举报