简体   繁体   English

如何在.classpath中添加对.propeties文件的引用

[英]How to add reference to .propeties file in .classpath

i've got exception, while running java class from Eclipse: 我从Eclipse运行Java类时遇到了异常:
java.util.MissingResourceException: Can't find bundle for base name dbconfig, locale en_US java.util.MissingResourceException:找不到基本名称为dbconfig的包,语言环境为en_US

Seems that my dbconfig.properties file isn't in classpath. 似乎我的dbconfig.properties文件不在类路径中。

  1. dbconfig.properties located in root of the project. 位于项目根目录中的dbconfig.properties

  2. Eclipse is ran with VM arguments(in Run configurations-->Arguments menu): Eclipse是使用VM参数运行的 (在“运行配置->参数”菜单中):
    -Dcom.xxx.db.cfg=dbconfig

  3. resource bundle is retrieved following way: rb=ResourceBundle.getBundle((String)System.getProperties().get("com.xxx.db.cfg")); 资源束的获取方法如下: rb=ResourceBundle.getBundle((String)System.getProperties().get("com.xxx.db.cfg"));

How to add reference to this property file in .classpath file? 如何在.classpath文件中添加对此属性文件的引用?

如果您的“ dbconfig.properties”文件位于项目下某个名为“ resources”的文件夹中,请右键单击“ resources”->“构建路径”->“用作源文件夹”

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”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM