简体   繁体   中英

Including properties file outside of WAR but inside classpath

So i have a web service which will be deployed as a war file (In Oracle Weblogic 12c), and they would like a properties.file outside of the war file (but in the classpath and not hardcoded path - which is what I have now)

All it will contain is

username=username
password=password

How would I go about setting/getting the file from the classpath? (And more importantly, where would this classpath be?)

Did you try to add it to managed node class path?

<domain> -> Environment -> Servers -> Configuration -> Server start: Class Path

Add full path to the file location and restart managed node.

If it is available from your classpath, then you can use either:

URL url = this.getClass().getResource("fileName");

Or

InputStream stream = this.getClass().getResourceAsStream("fileName");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM