因为是WEB环境,所以在查找文件时不能像main方法一样查找,比如写src/test.properties,在运行时时找不到的
文件路径需要改写成
xxx.class.getClassLoader() .getResource("").getPath().substring(1) + "test.properties"
WEB程序下 获取src目录下的properties
原文:http://elisazhang.blog.51cto.com/6332349/1749810