---
title: "spring的PropertyPlaceholderConfigurer 指向工程外路径"
author: "leichenlei"
date: "2014-11-25T17:25:51Z"
tags: []
categories: ["编程语言"]
slug: "spring-propertyplaceholderconfigurer"
draft: false
lastmod: "2014-11-25T17:25:51Z"
id: 2160440
url: "https://leichenlei.iteye.com/blog/2160440"
---

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>
```