【发布时间】:2013-03-01 14:40:31
【问题描述】:
我有占位符的基于注释的 bean 配置。 在这个占位符的帮助下,我可以很容易地使用我想要的属性值。
@Bean
public static PropertySourcesPlaceholderConfigurer initPlaceholder() {
PropertySourcesPlaceholderConfigurer placeholder = new PropertySourcesPlaceholderConfigurer();
placeholder.setLocation(new ClassPathResource("some.properties"));
placeholder.setIgnoreUnresolvablePlaceholders(true);
return placeholder;
}
如何使用 ${some.properties} 动态值设置此占位符?
placeholder.setLocation(new ClassPathResource(ANY_PROPERTIES));
我不能使用 initPlaceholder(String property)...
【问题讨论】:
-
那么,您想在不使用占位符的情况下获得财产吗?在这种情况下,我认为弹簧配置文件会更好......(根据某些配置文件选择属性文件)。
标签: java spring properties