@PropertySource注解
@PropertySource
:加载指定的配置文件
@ConfigurationProperties默认是从全局配置文件中获取值
若不是从全局配置文件中获取值 则须加上@PropertySource
注解来指定
@PropertySource的value值还可以传入数组的方式加载多个配置文件
person.name=陈涛
person.age=19
person.isStudent=true
person.birth=2020/01/01
person.maps.k1=v111
person.maps.k2=v211
person.lists=pico,tankman
person.dog.name=dog
person.dog.age=2
用@PropertySource注解指定配置文件:
@Component
@PropertySource(value = {
"classpath:person.properties"})
@ConfigurationProperties(prefix = "person")
public class Person {
private String name;
private Integer age;
p