Log4j配置文件位置+Spring中数据源配置文件位置
来源:互联网 发布:nginx 自定义访问策略 编辑:程序博客网 时间:2024/05/14 09:37
一.Log4j配置文件位置
1.自动加载
应用程序启动时,默认情况下会到src目录下寻找log4j.xml配置文件,若不存在,会继续寻找log4j.properties文件,只要找到其中一个就会加载该配置文件内容。
2.手动加载
如果将log4j.properties(或log4j.xml)放到其它目录下,比如下图中的位置,应用程序就不能自动加载log4j的配置文件了,因为应用程序找不到该配置文件,你需要手动加载。
需要在应用程序启动的代码中加入如下的代码:
//加载config文件夹下的log4j.propertiesString log4jPath=System.getProperty("user.dir")+"/config/log4j.properties";PropertyConfigurator.configure(log4jPath);
二.Spring中数据源配置文件位置
1.一般情况
比较常见的Spring加载数据源配置文件的方式如下:
<bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><list><value>classpath:dataSource.properties</value></list></property></bean>
这种方式是将dataSource.properties文件放在src的根目录下的。
2.其它位置
现在如果将dataSource.properties文件放在src同级的config的目录下,上面的配置方式就不行了,正确的配置方式如下:
<bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><list><value>file:config/dataSource.properties</value></list></property></bean>
交流探讨到我的新浪微博:http://weibo.com/tianrui1990
欢迎关注Java技术分享微信公众号:JavaQ
1 0
- Log4j配置文件位置+Spring中数据源配置文件位置
- Log4j配置文件位置+Spring中数据源配置文件位置
- log4j配置文件位置详解
- log4j配置文件位置详解
- log4j配置文件位置详解
- log4j配置文件位置详解
- Log4j-配置文件位置详解
- 自定义Log4j配置文件位置
- log4j配置文件位置详解
- log4j配置文件位置详解
- Spring配置文件的位置
- 自定义spring配置文件位置
- log4j配置文件相对位置分析
- 指定log4j配置文件的位置
- Log4j 配置文件放置位置说明
- log4j的配置文件log4j.properties存放位置
- 读取spring配置文件的位置
- 指定spring配置文件的位置
- GetLastError 返回值
- HTML禁止网页文字复制,禁止查看源代码
- zoj3547
- Could not find D:\software\adt-bundle-windows-x86...windows-x86-20140321\sdk\tools\emulator.exe!
- C# 委托
- Log4j配置文件位置+Spring中数据源配置文件位置
- 纵观钢厂自豪柜
- 前端开发学习笔记
- SVN提交文件后 show log不显示版本号
- 简单描述,预先设计的建筑物的好处
- C#修饰符和类
- spring jdbc 调用存储过程
- Java CXF调用PHP[其它语言]的Web Service
- 升级到Scriptcase 8.0的注意事项