【发布时间】:2020-03-05 08:44:45
【问题描述】:
对于 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'
【问题讨论】:
-
在下面发布了答案,让我们知道这是否有效
标签: java xml spring dependency-injection properties