maven加载不到配置文件

来源:互联网 发布:淘宝卖家借贷平台 编辑:程序博客网 时间:2024/05/21 17:31

1.之前是这么做的

PropertyConfigurator.configure("log4j.properties");

以为放在resources里面就可以直接读取,但是报异常

log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (系统找不到指定的文件。)

2.那就换一种方法

String path = OSSDemo.class.getClassLoader().getResource("log4j.properties").getPath();PropertyConfigurator.configure(path);
通过类加载器加载,就可以了

阅读全文
0 0
原创粉丝点击