SpringBoot_application.yaml配置

yaml语法

  • 普通的key-value, name: yang

  • 对象 student: {name: yang, age: 12}

  • 数组 pets: [cat,dog]

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

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

猜你喜欢

转载自www.cnblogs.com/yangzixiong/p/12928296.html