使Spring属性从属性文件自动刷新 [英] Having spring bean properties refreshed automatically from properties file

查看:812
本文介绍了使Spring属性从属性文件自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Spring 2.5.6。我有一个bean的属性是通过 PropertyPlaceholderConfigurer 。我想知道是否可能有属性的bean更新时,属性文件修改。例如,一些周期性过程检查属性文件的最后修改日期,如果它改变了,重新加载bean。

I'm using Spring 2.5.6. I have a bean whose properties are being assign from a property file via a PropertyPlaceholderConfigurer. I'm wondering whether its possible to have the property of the bean updated when the property file is modified. There would be for example some periodic process which checks the last modified date of the property file, and if it has changed, reload the bean.

我想知道是否有已经是满足我的要求的东西。如果没有,什么是解决这个问题的最佳方法?

I'm wondering if there is already something that satisfies my requirements. If not, what would be the best approach to solving this problem?

感谢您的帮助。

推荐答案

Spring的PropertyOverrideConfigurer。可以重新读取属性,并重新应用于某些轮询/ schedular bean。

Might also look into useing Spring's PropertyOverrideConfigurer. Could re-read the properties and re-apply it in some polling/schedular bean.

这取决于实际配置的bean如何使用这些属性。例如,他们可能会间接地将它们缓存在自己的某处。

It does depend on how the actual configured beans use these properties. They might, for example, indirectly cache them somewhere themself.

这篇关于使Spring属性从属性文件自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆