spring加载配制文件并引用

config.properties 

c3p0.driverClass=com.mysql.jdbc.Driver 
xxx=yyyy 

加载Properties配置文件

<bean id="applicationConfig" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
  <property name="order" value="1"/> 
  <property name="ignoreUnresolvablePlaceholders" value="true"/> 
  <!--外置配制-->
  <!-- <property name="location" value="file:/var/superaccount/config/config.properties"/> --> 
  <!--内置配制--> 
  <property name="location" value="classpath:config/config.properties"/>
</bean> 
或另一种写法
<context:property-placeholder location="classpath:jdbbc.properties,classpath:config/xxx.properties"/>

在配制文件引用加载的properties

<property name="driverClass" value="${c3p0.driverClass}" /> 

猜你喜欢

转载自blog.csdn.net/maqingbin8888/article/details/89104114