@ConfigurationProperties和@PropertySource

@ConfigurationProperties填充对象属性,它默认是从application.yml或application.properties上读,需要作为一个bean,所以还要加@Component或在配置类上加@Bean。

如果要指定配置文件就要加@PropertySource
@PropertySource(value = {"classpath:person.properties"})

https://blog.csdn.net/qq78442761/article/details/88115060

原文地址:https://www.cnblogs.com/kltsee/p/15170628.html