java.util.MissingResourceException [英] java.util.MissingResourceException
问题描述
我在运行应用程序时遇到异常。此应用程序读取abc.properties文件,
I am getting below exception while running an application. This application read abc.properties file,
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name abc, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:853)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:822)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:566)
at com.ibm.dst.DailyExtract.getResourceBundle(DailyExtract.java:104)
at com.ibm.dst.DailyExtract.main(DailyExtract.java:131)
abc.properties文件驻留在工作区。
我使用RSA7作为IDE,有任何设置问题吗?
欢迎任何建议.....
abc.properties file reside at the workspace. I am using RSA7 as IDE, is there any setting problem? any suggestions are welcome.....
非常感谢提前
推荐答案
按照这篇文章中的提示,看看你是否做了其中一个错误,可能是(从链接复制粘贴):
Follow the hints in this post and see if you made one of those mistakes, which could be (copy pasted from the link):
-
这些资源属性文件由类加载器加载,类似于java类。因此,您需要将它们包含在运行时类路径中。
These resource properties files are loaded by classloader, similar to java classes. So you need to include them in your runtime classpath.
这些资源具有完全限定资源名称,类似于完全限定类名称,摘录您无法将资源导入您的java源文件。为什么?因为它的名称采用字符串的形式。
These resources have fully-qualified-resource-name, similar to a fully-qualified-class-name, excerpt you can't import a resource into your java source file. Why? because its name takes the form of a string.
ResourceBundle.getBundle(config)
告诉使用默认包(即没有包)加载名为config的资源的类加载器。它并不意味着当前包中具有引用类的资源。
ResourceBundle.getBundle("config")
tells the classloader to load a resource named "config" with default package (that is, no package). It does NOT mean a resource in the current package that has the referencing class.
ResourceBundle.getBundle(com.cheng.scrap .config)
告诉类加载器使用包com.cheng.scrap加载名为config的资源。它的完全限定资源名称是com.cheng.scrap.config
ResourceBundle.getBundle("com.cheng.scrap.config")
tells the classloader to load a resource named "config" with package "com.cheng.scrap." Its fully-qualified-resource-name is "com.cheng.scrap.config"
这篇关于java.util.MissingResourceException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!