相关疑难解决方法(0)

如何在Web应用程序中读取属性文件?

属性文件位置是WEB-INF/classes/auth.properties.

我不能使用特定于JSF的方法(使用ExternalContext),因为我需要服务模块中的属性文件,该模块不依赖于Web模块.

我已经试过了

MyService.class.getClassLoader().getResourceAsStream("/WEB-INF/classes/auth.properties");
Run Code Online (Sandbox Code Playgroud)

但它回来了null.

我也试过阅读它,FileInputStream但它需要完整的路径是不可接受的.

有任何想法吗?

java properties

26
推荐指数
3
解决办法
7万
查看次数

标签 统计

java ×1

properties ×1