![](/img/trans.png)
[英]Spring - Using property-placeholder to load properties file that is outside the war file or the classpath but is in the filesystem
[英]Including properties file outside of WAR but inside classpath
所以我有一个将作为war文件部署的Web服务(在Oracle Weblogic 12c中),他们想在war文件之外的一个properties.file(但是在classpath而不是硬编码路径 - 这就是我现在拥有的)
它所包含的只是
username=username
password=password
我如何从类路径设置/获取文件? (更重要的是,这个类路径在哪里?)
您是否尝试将其添加到托管节点类路径?
<domain> -> Environment -> Servers -> Configuration -> Server start: Class Path
添加文件位置的完整路径并重新启动受管节点。
如果它可以从您的类路径中获得,那么您可以使用以下任一方法:
URL url = this.getClass().getResource("fileName");
要么
InputStream stream = this.getClass().getResourceAsStream("fileName");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.