[英]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.