Spring 的 分散装配

it2022-05-06  15

在应用上下文中,使用PropertyPLaceholderConfigurer从外部属性文件装载配置信息: Bean.xml配置文件 <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>jdbc.properties</value> <value>security.properties</value> <value>application.properties</value> </list> </property> </bean> Location属性允许使用单个配置文件,可使用其localtions属性设置配置文件列表; 这样就可以使用占位符变量代替Bean配置文件中硬编码配置了语法上采用${variable}的形式; <bean id="personServiceBean" class="cn.csdn.hr.service.PersonServiceBean" scope="prototype"> <property name="name"> <value>${name}</value> </property> <property name="sex"> <value>${sex}</value> </property> <property name="age"> <value>12</value> </property> </bean>

转载于:https://www.cnblogs.com/springside4/archive/2012/04/18/2481058.html


最新回复(0)