【发布时间】:2011-12-30 18:43:09
【问题描述】:
在一个 Maven 战争项目中,我使用 jetty-maven-plugin 作为开发容器。
我过滤了一些资源文件,特别是让我们将其命名为“bddconf.xml”。
这个文件被maven过滤并放在target/classes目录下。
用这个 sn-p 对这个文件进行旧的自制 bdd fwk 搜索:
Properties properties = new Properties();
InputStream inputstream = properties.getClass().getResourceAsStream("/bddconf.xml");
当我运行这个 sn-p 时,在我的 webapp(在码头)中,inputStream 为空。
而使用这个 sn-p,以相同的方法:
import com.google.common.io.Resources;
String file = Resources.getResource("bddconf.xml").getFile();
File file2 = new File(file);
logger.info("Does bdd file exists : [" + file2.exists() + "] file : [" + file2.toString() + "]");
// Does bdd file exists : [true] file : [..path..\target\classes\bbdconf.xml]
它有效,那么这两种方法有什么区别?
【问题讨论】:
标签: maven resources maven-jetty-plugin