如何在 .classpath 中添加对 .propeties 文件的引用
我在从 Eclipse 运行 java 类时遇到异常:
java.util.MissingResourceException:找不到基本名称 dbconfig 的包,区域设置 en_US
似乎我的 dbconfig.properties 文件不在类路径中。
dbconfig.properties 位于项目的根目录中。
Eclipse 使用 VM 参数运行(在“运行配置-->参数”菜单中):
-Dcom.xxx.db.cfg=dbconfig
资源包通过以下方式检索:
rb=ResourceBundle.getBundle((String)System.getProperties().get("com.xxx.db.cfg"));
如何在.classpath文件中添加对此属性文件的引用?
i've got exception, while running java class from Eclipse:
java.util.MissingResourceException: Can't find bundle for base name dbconfig, locale en_US
Seems that my dbconfig.properties file isn't in classpath.
dbconfig.properties located in root of the project.
Eclipse is ran with VM arguments(in Run configurations-->Arguments menu):
-Dcom.xxx.db.cfg=dbconfig
resource bundle is retrieved following way:
rb=ResourceBundle.getBundle((String)System.getProperties().get("com.xxx.db.cfg"));
How to add reference to this property file in .classpath file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的“dbconfig.properties”文件位于项目下的某个名为“resources”的文件夹中,请右键单击“resources”->“构建路径”->“用作源文件夹”
If your 'dbconfig.properties' file is in some folder called 'resources' under your project, Right Click on 'resources'->Build Path->Use as source folder
右键单击您的项目并选择“构建路径”-“配置构建路径”。这将打开一个包含四个选项卡的对话框,用于配置构建路径。如果您的属性文件已经在您的项目中,那么很可能已经在构建路径上,并且您只是错误地引用了它。
Right-click on your project and choose Build Path-Configure Build Path. This opens a dialog with four tabs for configuring the build path. If your properties file is already within your project is however most likely already on the build path and you are just referencing it incorrectly.
通过指定解决:classpathentry kind="lib" path="dbconfig.properties"
resolved by specifying: classpathentry kind="lib" path="dbconfig.properties"