refresh property placeholder mechanism at Spring

 ̄綄美尐妖づ 提交于 2019-12-23 01:54:39

问题


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?


回答1:


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;

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

Under the hood, this is using Guava's EventBus to update the properties of your beans after the bean has been created.



来源:https://stackoverflow.com/questions/20262868/refresh-property-placeholder-mechanism-at-spring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!