使用 Spring 3.0 EL 我们可以自动将属性从属性文件连接到组件吗?
我知道我们可以使用 Util
加载属性文件命名空间,我们可以将其作为 bean 访问,但我们可以使用 spring EL Autowiring 吗。
<util:properties id="myProperties" location="/WEB-INF/my.properties"/>
最佳答案
@Value("#{ myProperties['min.age.required'] }")
int age;
顺便说一句,好老<context:property-placeholder .../>
工作也很好:
@Value("${min.age.required}")
int age;
关于java - Spring 3.0 EL 如何从属性文件中获取属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2237924/