spring的properties文件一般会放到classpath下。最近有个项目是使用spring,但是是打成jar执行的。
config.properties 和jar放到同一个目录,为了让spring读到 config文件,使用下面的配置:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="order" value="1" /> <property name="systemPropertiesMode"> <value>1</value> </property> <property name="locations"> <list> <value>file:${user.dir}/config.properties</value> </list> </property> </bean>