Spring引入配置文件

通过在spring的配置文件中配置要引入的property文件

<context:property-placeholder ignore-resource-not-found="true"
			location="classpath*:/application.properties,
          			  classpath*:/application.development.properties,
          			  classpath*:/memcached.properties" />
然后就可以在其它标签中使用property文件中的参数

如memcached.properties中有如下数据

memcache.server=192.168.0.1:11211

则在spring的标签中就可以如下使用该值

<bean id="memcachedPool" class="com.danga.MemCached.SockIOPool" factory-method="getInstance" 
      init-method="initialize" destroy-method="shutDown">
		<constructor-arg><value>memCachedPool</value></constructor-arg>
		<property name="servers"><list><value>${memcached.server}</value></list></property>
</bean>


你可能感兴趣的:(spring)