【发布时间】:2012-11-24 04:29:45
【问题描述】:
在spring JavaConfig中,我可以定义属性源并注入到环境中
@PropertySource("classpath:application.properties")
@Inject private Environment environment;
如果在 xml 中,我该怎么做? 我正在使用 context:property-placeholder,并在 JavaConfig 类 @ImportResource 上导入 xml。但我无法使用 environment.getProperty("xx") 检索属性文件中定义的属性
<context:property-placeholder location="classpath:application.properties" />
【问题讨论】:
标签: java spring properties spring-environment