PropertyPlaceholderConfigurer

 * A property resource configurer that resolves placeholders in bean property values of
 * context definitions. It <i>pulls</i> values from a properties file into bean definitions.

xml 代码
 
  1. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  2.     <property name="locations">  
  3.         <list>  
  4.             <value>classpath:hibernate.properties</value>  
  5.             <value>classpath:framework.properties</value>  
  6.         </list>  
  7.     </property>  
  8. </bean>  


${hibernate.connection.driver_class}
通过以下方式可以在spring配置文件中引用properties文件中定义的变量
hibernate.connection.driver_class=××××××

你可能感兴趣的:(spring,Hibernate,bean,xml)