问题
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