1.单独属性中读取

  1. //配置类原文
  2. china:
  3. compony:
  4. name: 畅由
  5. adress: 深圳
  6. email: 23048043980
  7. //单独读取属性
  8. @Value("${china.compony.nam}") String name;

2.创建配置类对象

@ConfigurationProperties(prefix = "china.compony")
public class ComponyConfig {
    private String name;
    private String adress;
    private String email;

}