且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在类路径上添加外部资源(属性文件),以便可以读取war?

更新时间:2023-11-16 16:53:40

我有类似的要求,并且执行了以下操作:

I had the similar requirement and I did the followings:

1)在catalina.properties中添加了针对shared.loader的properties文件夹路径。
示例:

1) Added the properties folder path against shared.loader in catalina.properties. Example:

    shared.loader="c:/ExternalResource"

2)然后使用以下内容读取属性:-

2) Then read the properties using the following :-

Thread.currentThread().getContextClassLoader().getResourceAsStream(propertiesFileName)