【发布时间】:2013-06-06 00:31:56
【问题描述】:
当我尝试运行我的JerseyTest 时,来自我的源 (src/main/resources) 文件夹 keepa 的 my.properties 文件被拾取并使用......而我想要测试文件夹中的属性文件 (src/test/resources ) 来使用。
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
myProperties.load(classLoader.getResourceAsStream("my.properties"));
}
如何在 Maven 中进行配置?
我正在使用:
-
maven-compiler-plugin版本2.1 -
jersey-test-framework-grizzly2版本1.13
更新(根据接受的答案解决):
我注意到文字skip non existing resourceDirectory:
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ xxx ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /xxx/xxx/xxx/xxx/src/test/resources
原来我拼错了资源,修复它后,一切都按照接受的答案中的描述工作。
当我浪费时间寻找解决方法时,我确实找到了一些有趣的链接,用于基于配置文件配置属性文件:
【问题讨论】:
标签: maven junit jersey grizzly