@Order(1)publicclassLocalPropertiesPropertySourceextendsAbstractSimplePropertySourceimplementsInitializingBean{@AutowiredprivateApplicationEventPublisherpublisher;privateReloadingFileBasedConfigurationBuilder<PropertiesConfiguration>builder;privatestaticfinalStringDEFAULT_LOCAL_PROPERTIES_PATH="sysoptions.properties";publicLocalPropertiesPropertySource(){super(ENV_PREFIX+"local_properties");log.debug("开发环境,启用[{}]配置",getClass());}@OverridepublicvoidafterPropertiesSet(){IntegersysOptionsLoadInterval=getEnvironment().getProperty("dev.localPropertiesLoadInterval",Integer.class,1);StringsysOptionsPath=getEnvironment().getProperty("dev.localPropertiesPath",DEFAULT_LOCAL_PROPERTIES_PATH);FilepropertiesFile=newFile(sysOptionsPath);if(!propertiesFile.exists()){return;}// server boot will publish eventpublisher.publishEvent(newLocalProperitesReReloadingEvent(newObject(),propertiesFile.getAbsolutePath()));builder=newReloadingFileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(newParameters().fileBased().setFile(propertiesFile));ReloadingControllerreloadingController=builder.getReloadingController();reloadingController.addEventListener(ReloadingEvent.ANY,e->publisher.publishEvent(newLocalProperitesReReloadingEvent(e,propertiesFile.getAbsolutePath())));PeriodicReloadingTriggertrigger=newPeriodicReloadingTrigger(reloadingController,null,sysOptionsLoadInterval,SECONDS);trigger.start();}@OverridepublicObjectgetProperty(@NonNullStringname){if(builder==null)returnnull;Configurationconfiguration=null;try{configuration=builder.getConfiguration();Stringconfig_value=configuration.getString(name);if(config_value!=null){returnconfig_value;}}catch(ConfigurationExceptione){log.error(e.getMessage(),e);}returnnull;}}