读写nacos的配置中心的参数及变动监听
转摘:https://rocklee.blog.csdn.net/article/details/124006422?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-124006422-blog-126297104.pc_relevant_multi_platform_featuressortv2dupreplace&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-124006422-blog-126297104.pc_relevant_multi_platform_featuressortv2dupreplace&utm_relevant_index=1
import com.purgeteam.dynamic.config.starter.event.ActionConfigEvent; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.Map; @Component public class NacosListener implements ApplicationListener<ActionConfigEvent> { /** 日志 */ private static final Logger log = LogManager.getLogger(Nacoslistener.class); @Override public void onApplicationEvent(ActionConfigEvent environment) { Map<String, HashMap> map = environment.getPropertyMap(); for (Map.Entry<String, HashMap> entry : map.entrySet()) { String key = entry.getKey(); Map changeMap = entry.getValue(); String before = String.valueOf(changeMap.get("before")); String after = String.valueOf(changeMap.get("after")); if(log.isInfoEnabled()){ log.info("配置[key:{}]被改变,改变前before:{},改变后after:{}",key,before,after); } } } }
https://blog.csdn.net/meser88/article/details/115135026?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-115135026-blog-122356374.pc_relevant_3mothn_strategy_and_data_recovery&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-115135026-blog-122356374.pc_relevant_3mothn_strategy_and_data_recovery&utm_relevant_index=1