springboot使用PropertyResource注解读取指定配置文件的属性(传智播客代码)
接上篇: SpringBoot/Spring使用@Value进行属性绑定(传智播客代码) ConfigurationProperties注解默认会从全局配置文件读取属性 ,当属性多的时候,主配置文件( application.yml、application.properties)会臃肿,因此有必要把某一类别属性单独分开配置 @PropertyResource读取指定配置文件 该注解的value支持string数组,可以填写多个配置文件路径,例如 @PropertyResource(value={"aaa.properties","classpath:bbb.properties"}) Person.java package com.atguigu.bean; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype