-1
我看了這個問題的答案,但他們沒有爲我工作。 我在Resources文件夾中有一個名爲「config_en.properties」的文件。 (項目 - >資源 - > config_en.properties)java.util.MissingResourceException:無法找到基本名稱配置,區域設置en
jms_Address=t3://127.0.0.1:7101
connection_Lookup_Address=BatchApp-BatchGebelikTakip-BatchGebelikTakipEJB#tr.com.surat.esaglik.batch.ejb.IBatchGebelikTakipEJB
而在我的Java類中我嘗試讀取這個配置:
private static final String fileName="config";
public static final String jms_Address="jms_Address";
public static final String conn_Lookup_Address="connection_Lookup_Address";
private static ResourceBundle res;
private static ClassLoader cl;
static {
try {
cl = Thread.currentThread().getContextClassLoader();
res = ResourceBundle.getBundle(fileName, Locale.ENGLISH, cl);
} catch (Exception e) {
e.printStackTrace();
}
}
public void test(){
System.out.println(res.getString(jms_Address).
}
但我得到這個錯誤信息:
java.util.MissingResourceException: Can't find bundle for base name config, locale en
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:952)
at tr.com.surat.esaglik.batch.Main.<clinit>(Main.java:34)
java.lang.NullPointerException
at tr.com.surat.esaglik.batch.Main.getInitialContext(Main.java:74)
at tr.com.surat.esaglik.batch.Main.run(Main.java:43)
什麼是錯的?
我試過,但沒有奏效。 – yetAnotherSE 2012-08-13 11:07:06
發佈更新... – evg 2012-08-13 11:15:01