spring 定時刷新配置文件
阿新 • • 發佈:2018-05-11
spring 定時刷新配置文件public class TestResource {
public static void main(String[] args) { ResourceLoader resourceLoader = new DefaultResourceLoader(); ReloadableResourceBundleMessageSource auto = new ReloadableResourceBundleMessageSource(); String[] basenames = {"filename"}; auto.setBasenames(basenames); auto.setResourceLoader(resourceLoader); auto.setCacheSeconds(5); auto.setUseCodeAsDefaultMessage(true); while(true) { System.out.println(auto.getMessage("key", null, Locale.CHINESE)); try { Thread.sleep(5*1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
}
spring 定時刷新配置文件