Bla*_*man 2 java junit web-applications classpath
我有一个属性文件,我目前在此文件夹中:
/src/webapp/WEB-INF/classes/my.properties
Run Code Online (Sandbox Code Playgroud)
我正在加载它:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream is = classLoader.getResourceAsStream("/my.properties");
Properties props = new Properties();
try {
props.load(is);
} catch (IOException e) {
e.printStackTrace();
}
String test = props.getProperty("test");
Run Code Online (Sandbox Code Playgroud)
现在这在我的Spring mvc应用程序中运行良好.
但是当我为此创建测试时,它失败并且我假设因为应用程序加载它的方式不使用web-inf/classes,因为它只是一个类而不是一个spring web应用程序.
那么我在哪里放置我的属性文件,以便在我的junit测试运行时,拾取属性文件?
此外,对于我的Web应用程序,除了/ web-inf/classes之外,还有哪些其他文件夹位于默认类路径中?
| 归档时间: |
|
| 查看次数: |
4517 次 |
| 最近记录: |