继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

ResourseBundle的使用之Can't find bundle for base name

小花要努力奋斗
关注TA
已关注
手记 2
粉丝 2
获赞 4

代码:
Locale myLocale = Locale.getDefault(Locale.Category.FORMAT);
//读取属性文件常用到的ResourceBundle类
ResourceBundle rb = ResourceBundle.getBundle("jdbc.properties",myLocale);
Enumeration<String> keys = rb.getKeys();
while(keys.hasMoreElements()){
System.out.println(keys.nextElement());
}
String addr = rb.getString("jdbcUrl")+","
+rb.getString("username")+","
+rb.getString("password");

    System.out.println(addr);

异常:
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name jdbc.properties, locale zh_CN
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:796)
at hua.path.MainPath.main(MainPath.java:48)

解决:将jdbc.properties改为jdbc即可。

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP