Monitor Spring properties files and Refresh

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.