1.<context:property-placeholder location="jdbc.properties"/>
不过这种方法要在beans.xml头部配置命名空间:
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd'
2.这种方法不需要配置命名空间
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties" />
</bean>
本文介绍了两种在Spring中使用属性文件的方法。一种是在beans.xml中通过context:property-placeholder配置,需声明特定命名空间;另一种则利用PropertyPlaceholderConfigurer Bean进行配置,更为灵活便捷。
1228

被折叠的 条评论
为什么被折叠?



