07【掌握】springboot的两种配置文件语法
解决提示问题

创建Student
@ConfigurationProperties(prefix=”student”)
Springboot标记了IOC容器里面一个对象
当IOC里面的对象初始化完成之后,再去扫描ConfigurationProperties
然后把配置文件里面是student前缀开头的配置注入到IOC这个对象的相应的set方法里面

使用application.properties的文件注入

使用application.yml的文件注入

配置文件占位符


两种方法的说明
1,如果properties里面配置了就不会去yml里面去取值,如果没有配置就会去yml里面去取
2,两种配置方法是互补的
网友评论