刷新Spring的属性占位符机制 [英] refresh property placeholder mechanism at Spring
问题描述
我有一个 Spring
上下文xml文件以及一个由 PropertyPlaceholderConfigurer
机制创建的特定bean。
我的问题是:当应用程序正在运行相关的属性文件更改而我不想重启应用程序。我想重新加载相关bean而不重启应用程序。
I have a Spring
context xml file and a specific bean into it that created by a PropertyPlaceholderConfigurer
mechanism.
My problem is: When the application is working related properties file changes and I don't want restart application. I want reload related bean without restart application.
什么是我的目标的最佳解决方案?
What is best solution for my goal?
推荐答案
you can have a look at ReloadablePropertiesAnnotation
on github https://github.com/jamesemorgan/ReloadablePropertiesAnnotation
这应该只是通过注释您的属性来工作,如
this should just work by annotating your property like
@ReloadableProperty("dynamicProperty.myProperty")
private String myProperty;
你必须添加一些弹簧配置以及github或本博客中的示例< a href =http://www.morgan-design.com/2012/08/reloadable-application-properties-with.html =nofollow> http://www.morgan-design.com/2012/ 08 / reloadable-application-properties-with.html
you'll have to add some spring configuration as well see the example on github or in this blog http://www.morgan-design.com/2012/08/reloadable-application-properties-with.html
在幕后,这是使用Guava的EventBus来更新bean之后的bean的属性已创建。
Under the hood, this is using Guava's EventBus to update the properties of your beans after the bean has been created.
这篇关于刷新Spring的属性占位符机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!