扫码关注官方订阅号
走同样的路,发现不同的人生
先回答在哪PropertiesLoaderSupport这个抽象类,是PropertyPlaceholderConfigurer父类,Properties文件的位置是在这里设置。
PropertiesLoaderSupport
PropertyPlaceholderConfigurer
Properties
public void setLocation(Resource location) { this.locations = new Resource[] {location}; }
再回答什么时候如果了解一点spring源码,会看到spring容器启动都是通过调用refresh方法实现。在refresh中有一个方法调用invokeBeanFactoryPostProcessors(beanFactory)的作用就是去实现BeanFactoryPostProcessor这个接口的方法
spring
refresh
invokeBeanFactoryPostProcessors(beanFactory)
BeanFactoryPostProcessor
void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;
而PropertyPlaceholderConfigurer的一个父类PropertyResourceConfigurer就实现了这个接口,所以spring在完成BeanFactory的初始化时就会调用上述提到的方法。
PropertyResourceConfigurer
BeanFactory
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
先回答在哪
PropertiesLoaderSupport
这个抽象类,是PropertyPlaceholderConfigurer
父类,Properties
文件的位置是在这里设置。再回答什么时候
如果了解一点
spring
源码,会看到spring
容器启动都是通过调用refresh
方法实现。在refresh
中有一个方法调用invokeBeanFactoryPostProcessors(beanFactory)
的作用就是去实现BeanFactoryPostProcessor
这个接口的方法而
PropertyPlaceholderConfigurer
的一个父类PropertyResourceConfigurer
就实现了这个接口,所以spring
在完成BeanFactory
的初始化时就会调用上述提到的方法。