对于通过使用属性文件中的值的设置器在xml中进行DI,我可以使用:
<beans>
..
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="props.properties"/>
</bean>
<bean id="first" class="..">
<property name="name" value="${values.name}"/>
</bean>
</beans>
但是不推荐使用PropertyPlaceholderConfigurer
类。
我尝试使用
<context:property-placeholder location="classpath:props.properties"/>
代替它,但是没有用
prop.properties
位于resources
中,错误消息为no declaration can be found for element 'context:property-placeholder'