在ApplicationContext.xml中配置
<bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:imgConfig.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="properties" ref="configProperties" />
</bean>
创建配置文件 imgConfig.properties
imgUploadUrl=C:/develop/upload/image/
使用@Value获取属性
@Value("#{configProperties['imgUploadUrl']}")
private String imgUpload;