Log4j配置文件位置+Spring数据源配置文件位置
一个.Log4j配置文件位置
1.加载自己主动
当应用程序启动,缺省情况下,这将是src文件夹搜索log4j.xml型材。如果不存在。我们将继续寻找log4j.properties文件,仅仅要找到当中一个就会载入该配置文件内容。
2.手动载入
假设将log4j.properties(或log4j.xml)放到其他文件夹下,比方下图中的位置,应用程序就不能自己主动载入log4j的配置文件了,由于应用程序找不到该配置文件,你须要手动载入。
须要在应用程序启动的代码中增加例如以下的代码:
//载入config目录下的log4j.properties
String 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
版权声明:本文博客原创文章,博客,未经同意,不得转载。
Log4j配置文件位置+Spring数据源配置文件位置的更多相关文章
- 日志配置文件读取spring boot配置文件中的属性
如果是读取 application.properties 这种spring boot的默认配置文件时 其中 scope固定为context 指明从上下文中获取, name 根据自己的意思给, sou ...
- spring配置文件和spring mvc配置文件的区别
Question: Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will ...
- Spring分配置文件开发
---------------------siwuxie095 Spring 分配置文件开发 Spring 分配置文件开 ...
- Spring boot 配置文件默认放置位置,和加载优先级
一 .默认配置文件目录 spring boot 启动会扫描以下位置的application.properties 或者application.yml文件作为spring boot 的默认配置文件 ,加 ...
- Spring Boot配置文件大全
Spring Boot配置文件大全 ############################################################# # mvc ############## ...
- Spring的配置文件 (SSM maven项目)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Spring的配置文件
Web.xml将会配置Spring的配置文件位置: <servlet> <servlet-name>x</servlet-name> & ...
- Spring boot 配置文件详解 (properties 和yml )
从其他框架来看 我们都有自己的配置文件, hibernate有hbm,mybatis 有properties, 同样, Spring boot 也有全局配置文件. Springboot使用一个全局的配 ...
- Springboot 系列(二)Spring Boot 配置文件
注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别. 前言 不管是通过官方提供的方式获取 Spring ...
随机推荐
- Revit 2015 公布!
Revit 2015 公布了, 如今能够下载.大家能够搜索下中文版的下载. 之前就知道2015 的模型操作速度再次提高, 2015安装后的马上载入跑了一个模型.果然,2015 打开自带的高级模型,不管 ...
- Nginx安装手冊以及图片server部署
1. 安装gcc yum install gcc 2. 安装pcre,pcre-devel 在zhoulh文件夹下建立source build文件夹 mkdir source bu ...
- POJ 2536 Gopher II(二分图的最大匹配)
题目链接:http://poj.org/problem?id=2536 题意:已知有n仅仅老鼠的坐标,m个洞的坐标,老鼠的移动速度为V,S秒以后有一仅仅老鹰要吃老鼠,问有多少个老鼠被吃. 非常明晰,二 ...
- 自定义ComboBox,简简单单实现
private void Button_Click(object sender, RoutedEventArgs e) { Popup1.PlacementTarget = TesTextBox; P ...
- java获取指定地址图片高度宽度简单代码
package com.test; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.In ...
- HDU1176_免费馅饼【号码塔】
免费馅饼 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- C++-传值与传引用的差别
//值传递与引用传递的差别 #include <iostream> #include <iomanip> using namespace std; void fiddle(in ...
- WPF Media 简单的播放器
<Window x:Class="PlayTest.MediaControl" xmlns="http://schemas.microsoft.com/winfx/ ...
- centos6.4设备hadoop-2.5.1(完全分布式)
环境介绍: 在这两种装备centos6.4(32位置)的server安装Hadoop-2.5.1分布式集群(2台机器,主要试验用.哈哈). 1.改动主机名和/etc/hosts文件 1)改动主机名(非 ...
- 【HDU】5256 系列转换(上涨时间最长的序列修饰)
假设a[i]和a[j]我想的一样,满足条件的需要是 a[j] - a[i] > j - i 也就是说,a[i] - i < a[j] - j 例1 4 2 不满意,所以1和2必须有必要之间 ...