I have a problem ."This is just a configuration which I would like to manage during runtime. I don't want to redeploy whole app to update configuration".I am reading some values from the property files.How can i acheive this?
Asked
Active
Viewed 88 times
2 Answers
0
There are lots of possible solutions, depending on the exact need (and this like possibility to reload these properties on demand etc.).
The simplest one seems to be this one:
- Create a bean that internally has a cache defined (like Guava Cache)
- Set certain TTL for the cache contents (this will cause your properties to be reloaded every
TTL
seconds) - Provide a way to populate the cache
- Optionally provide a way to force refresh of cache contents
As for the last point I cannot give you a way to do this because I know nothing of your project, but there are at least few good options here depending on the project you are working on.

Rafal G.
- 4,252
- 1
- 25
- 41
0
Assuming your file is not part of deployable (WAR/EAR/JAR), you can watch for directory changes and identify whether your file has changed (refer Can I watch for single file change with WatchService (not the whole directory)?). Once you notice the file has changed, you can execute your logic.

Community
- 1
- 1

CuriousMind
- 3,143
- 3
- 29
- 54