type
status
date
slug
summary
tags
category
icon
password
把配置中的属性值,赋值到类中的属性中
创建一个类,绑定配置文件的某一个配置

image-20220817111931166

image-20220817111939790
指定前缀后,配置文件会进行一一对应,给相同的属性赋值。
测试值是否已经赋上
请求返回对象

image-20220817113159120
结果:

image-20220817113212243
总结:
想要把配置中的属性值加入到类中,需要使用@ConfigurationProperties指定前缀,类中的属性名和配置文件中的属性名一致,还需要使用@Component注册到容器中,就可以完成属性的配置。