现在的位置: 首页 > 综合 > 正文

spring容器,很好用

2013年09月07日 ⁄ 综合 ⁄ 共 484字 ⁄ 字号 评论关闭

关键字: 容器

BeanFactoryPostProcessor 接口是对Bean 工厂的后处理操作。

在Spring 的PropertyPlaceholderConfigurer 类是实现BeanFactoryProcessor 接口中非常有用的类。它用于Spring 从外部属性文件中载入属性,并使用这些属性值替换Spring 配置文件中的占位符变量(${varible})。

Spring 的ApplicationContext 容器可以非常方便的使用PropertyPlaceholderConfigurer,只需通过简单的配置即可使用。

示例:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="jdbc.properties" />
</bean>

如果需要使用多个配置文件可以使用PropertyPlaceholderConfigurer 的locations属性。

抱歉!评论已关闭.