【发布时间】:2017-06-26 23:17:14
【问题描述】:
我的配置如下:
@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。
我试图用谷歌搜索它,但没有一个答案给我解决方案。 :(
感谢您的帮助。
【问题讨论】:
标签: java spring-mvc spring-boot properties-file