[英]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) 所以我有一个将作为war文件部署的Web服务(在Oracle Weblogic 12c中),他们想在war文件之外的一个properties.file(但是在classpath而不是硬编码路径 - 这就是我现在拥有的)
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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.