文件我已經配置如下:更新值上運行
@Configuration
public class PropertyConfiguration {
@Bean
@Profile("local")
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
configurer.setLocation(new FileSystemResource("path/to/resources/app-local.properties"));
configurer.setIgnoreUnresolvablePlaceholders(true);
return configurer;
}
}
我app-local.properties
文件包含值:
cache.time.milliseconds=1000
所以,我訪問值:
@Value("${cache.time.milliseconds}")
private long cachingTime;
我收到了正確的值。
System.out.println(cachingTime);
現在,我要更新cachingTime
其他一些價值,服務其更新值。例如,從1000到99.
有什麼辦法可以在運行時更新這個屬性值?
或者除了重新啓動應用程序或服務器之外,還有其他更新此值的方式嗎?
我正在使用Spring Boot 1.4.3.RELEASE。
我試圖谷歌它,但沒有答案給了我解決方案。 :(
感謝您的任何幫助。
我知道......但我的要求是我不應該重啓服務器或應用程序。 :) –
沒有其他選擇 –