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>
本文介绍了Spring框架中如何使用属性配置文件来存放应用的设定值。主要讲述了两种方式:通过注解和通过bean定义来实现属性占位符的加载。文中详细展示了不同版本Spring配置属性文件的方法。
1886

被折叠的 条评论
为什么被折叠?



