我的Spring Boot应用程序中有一个备用application.properties(在外部文件夹中,而不在资源中),该属性是用PropertySourcesPlaceholer定义的:
@Configuration
public class MyApplicationProperties {
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurerAplicaciones() throws IOException {
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
File file = ResourceUtils.getFile(myApplicationLocation());
properties.setLocation(new FileSystemResource(file));
properties.setIgnoreResourceNotFound(true);
return properties;
}
然后加载类似in的属性
@Value("${host}")
private String host;
当我更改属性文件中的值时,Spring不会重新加载其值。
是否有一种方法可以强制加载该属性?