`

spring管理properties文件加载

阅读更多

spring中property用来存放application的设定值。

在applicationContext.xml中load进去,spring中定义了二种方式

1. 注解

    spring2.5

<context:property-placeholder location="classpath*:*.properties"/>  

    spring3.0

<context:property-placeholder location="classpath:file1.properties,classpath:file2.properties,classpath:file3.properties" ignore-unresolvable="true"/>

 

 

2. bean

	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
		<property name="ignoreResourceNotFound" value="true" />
		<property name="locations">
			<list>
				<value>classpath*:/application.properties</value>
				<value>classpath*:/×.properties</value>
			</list>
		</property>
	</bean>

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics