Brief introduction:
Monitor the properties file of the spring configuration and automatically restart the spring when the configuration file is modified
This plugin is intended for clustered Web applications, and the configuration center manages configuration files
principle :
Use Applicationlistener#onapplicationevent Monitor to configure Spring boot, turn on monitoring thread confmonitormain#start when boot is complete, When a configuration file is modified Confmonitormain notify Confchangedlistener#filechanged, the specific implementation has a default Defaultconfchangedlistener, Defaultconfchangedlistener#filechanged will restart Spring (destroy Create bean and reload properties)
The implementation of Defaultconfchangedlistener is also using applicationlistener#onapplicationevent to monitor spring's start-up and log applicationcontext, SPRINGMVC mode will have 2 configurableapplicationcontext, so you need to use sprintcontextlist record, when the filechanged is triggered, Traverse Sprintcontextlist for Refresh to complete spring restart
Schematic diagram:
Instructions for use :
Https://github.com/blackshadowwalker/spring-conf/wiki
Source :
Https://github.com/blackshadowwalker/spring-conf
Extended Development :
1. Custom Confchangedlistener for processing, such as restart WEBAPPP, etc.
2. local file monitoring using NIO
3. Remote file (HTTP) Use Zookeeper for change notification
4. Setting up a configuration Management center
Monitor Spring properties files and Refresh