spring 对于properties 配置文件动态刷新的问题
环境
Spring 4 MVC,Quartz,没有web。纯粹的JAVA程序
需求,有个配置文件 conf. properties,内容如下
tablename=test,test2
启动程序后spring注入配置文件。程序可以获取tablename的值,
现在问题是,程序运行过程中,修改conf.properties 文件中tablename的值为: com,com1,获取的仍是变动之前的值:test,test2
请问如何动态刷新这个配置文件的值,再不重启程序的情况下。
以下是spring配置文件:
<!-- 将多个配置文件位置放到列表中 -->
<bean id="propertyResources" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>file:conf/config.properties</value>
</list>
</constructor-arg>
</bean>
<!-- 将配置文件读取到容器中,交给Spring管理 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" ref="propertyResources" />
</bean>
在线急等。。。