【发布时间】:2011-10-25 06:06:52
【问题描述】:
我已经尝试寻找在 Spring 3 中使用 @Value 批注来使用 Spring EL 从属性文件中读取值的示例,但我没有找到一个好的示例。
这是我见过的一些组成部分来实现这一点,但我不知道所有这些如何协同工作以从属性文件中读取
<util:properties id="ewConfiguration" location="classpath:ew.properties"/>
现在,我如何在我的类中使用它从 ew.properties 文件中检索值以将它们绑定到实例变量?
例如,如果存在一个属性 url=www.google.com
我有
@Configuration
class AppConfig {
@Value("???")
private String url //what do I use in the place of the ??? to bind the value of the url property
// in the properties file to this instance variable ?
}
【问题讨论】:
标签: spring annotations