解决Spring配置文件无法读取properties属性问题
2015-09-26 20:30
881 查看
在Spring项目的配置文件中引用properties属性文件中的属性,运行时无法识别properties属性文件中的属性引用,但properties属性文件和属性明明已经存在,例如:
要在Spring中使用外部properties属性文件,需要在Spring配置文件中添加bean后处理器PropertyPlaceholderConfigurer,并指明外部properties属性文件的路径:
如果有多个properties属性文件,可以使用下面方式:
要在Spring中使用外部properties属性文件,需要在Spring配置文件中添加bean后处理器PropertyPlaceholderConfigurer,并指明外部properties属性文件的路径:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations" value="properties路径"/> </bean>
如果有多个properties属性文件,可以使用下面方式:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>properties路径</value> <value>properties路径</value> ... </list> </property> </bean>
相关文章推荐
- 一个jar包里的网站
- 一个jar包里的网站之文件上传
- 一个jar包里的网站之返回对媒体类型
- Powershell Profiles配置文件的存放位置介绍
- PowerShell入门教程之创建和使用配置文件实例
- SERV-U 的配置文件详解
- php.ini 配置文件的深入解析
- redis2.8配置文件中文翻译版
- PHP配置文件php.ini中打开错误报告的设置方法
- C#中读取App.config配置文件代码实例
- spring+html5实现安全传输随机数字密码键盘
- Spring中属性注入详解
- c++实现逐行读取配置文件写入内存的示例
- 关于session在PHP5的配置文件中的详细设置参数说明
- struts2 spring整合fieldError问题
- MySQL 配置文件my.cnf 例子最详细翻译
- apache 配置文件解说
- Android 读取Properties配置文件的小例子
- PHP 配置文件中open_basedir选项作用