2

I knew with Spring Cloud and some external configuration service (such Consul), when a property value changed, the Spring Cloud apps can retrieve the new value and refresh the Environment of the apps. The question is whether there is a similar solution for Spring Boot apps?

In my case, I have an app using a DB as its persistent store. The password of the DB will be changed daily, and the new password will be sent as a message. The app can get the new password from the message successfully, but I've got no idea to replace the old one.

Tonny Tc
  • 852
  • 1
  • 12
  • 37
  • https://stackoverflow.com/questions/52594764/how-to-hot-reload-properties-in-java-ee-and-spring-boot/52648630#52648630 might help – seenukarthi Feb 24 '20 at 03:42
  • Thanks a lot for your reply. Finally, I found the article: "Dynamic Configuration Properties in Spring Boot and Spring Cloud" (https://gist.github.com/dsyer/a43fe5f74427b371519af68c5c4904c7). – Tonny Tc Feb 24 '20 at 12:07
  • Even if this is possible to achieve, I don't think your password change refresh is a good use case but rather asking for trouble. This is because there is a period of time between the moment password is changed and the time your data source gets reconfigured in which the old password no longer active may be used. Most of the database vendors would look the account on three consecutive login failures and you don't want this in prod. Plus if you use connection pools you need to manually do some clean up. There are better ways to secure access to db rather than changing the password daily – Julian Feb 24 '20 at 20:02
  • @Julian Your opinion is extremely correct.In fact, the new username together with password will be generated and the old credentials will be removed in my case, and also it is a business requirement of my case. So there may be a trade-off between rebooting the service and refreshing it. – Tonny Tc Feb 25 '20 at 02:10

0 Answers0