6

I have externalized all my application needed property files from webapps in tomcat. Now i can simply change a property file value without a need of rebuilding the war file and deploy it again. However each change to property file is associated with server recyling.

Is there a way how the recycling can be avoided for a property file change. I am using spring to read the property files for few webapps and java property traditional way for few webapps.

Please suggest how to acheive

user2585494
  • 483
  • 2
  • 7
  • 18
  • possible duplicate of [How can I reload properties file in Spring 4 using annotations?](http://stackoverflow.com/questions/26150527/how-can-i-reload-properties-file-in-spring-4-using-annotations) – kryger Aug 22 '15 at 19:36
  • what approach you followed? – Abdullah Khan Aug 10 '17 at 07:40

2 Answers2

3

You may want to consider spring-cloud-config-server or spring-cloud-consul all of these options supports distributed properties management as well as value changes refresh without a need to recycle app servers.

And you can use @RefreshScope for Spring @Beans that want to be reinitialized when configuration changes, they also provide the following Management endpoints out of the box and many more as explained on the project git page

  • /refresh for refreshing the @RefreshScope beans
  • /restart for restarting the Spring context (disabled by default)

This is supported by either option (spring-cloud-config-server or spring-cloud-consul)

iamiddy
  • 3,015
  • 3
  • 30
  • 33
  • This works for only Git repo as location for all the property files. How about native profile, with file back-end system for the properties? – pramodc84 Apr 10 '18 at 04:22
1

You may also give cfg4j a try. It supports reloading configuration from local files as well as remote services (git repository, Consul, etc.).

PanHrabia
  • 174
  • 1
  • 4