@Component
@Data
@ConfigurationProperties(prefix = "person")
public class Person{
    private String id;
    private String name;
}
}

  @ConfigurationProperties括号中的prefix值即为application.yml文件中的前缀

#Person Info
person:
  id: student
  name: aaa

  在之后的运用中,可直接调用Person类(放在common/property中),可避免代码冗余

相关文章:

  • 2022-01-11
  • 2022-01-22
  • 2022-02-08
  • 2022-02-06
  • 2023-02-07
  • 2022-12-23
猜你喜欢
  • 2021-07-15
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-09-11
相关资源
相似解决方案