eclipse 如何在 .classpath 中添加对 .propeties 文件的引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3341884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add reference to .propeties file in .classpath
提问by sergionni
i've got exception, while running java class from Eclipse:
java.util.MissingResourceException: Can't find bundle for base name dbconfig, locale en_US
我在从 Eclipse 运行 java 类时遇到异常:
java.util.MissingResourceException: 找不到基本名称 dbconfig、locale en_US 的包
Seems that my dbconfig.propertiesfile isn't in classpath.
似乎我的dbconfig.properties文件不在类路径中。
dbconfig.propertieslocated in root of the project.
Eclipse is ran with VM arguments(in Run configurations-->Argumentsmenu):
-Dcom.xxx.db.cfg=dbconfig
resource bundle is retrieved following way:
rb=ResourceBundle.getBundle((String)System.getProperties().get("com.xxx.db.cfg"));
dbconfig.properties位于项目的根目录中。
Eclipse 使用 VM 参数运行(在运行配置--> 参数菜单中):
-Dcom.xxx.db.cfg=dbconfig
资源包通过以下方式检索:
rb=ResourceBundle.getBundle((String)System.getProperties().get("com.xxx.db.cfg"));
How to add reference to this property file in .classpath file?
如何在 .classpath 文件中添加对此属性文件的引用?
回答by Adisesha
If your 'dbconfig.properties' file is in some folder called 'resources' under your project, Right Click on 'resources'->Build Path->Use as source folder
如果您的“dbconfig.properties”文件位于项目下名为“resources”的文件夹中,请右键单击“resources”->构建路径->用作源文件夹
回答by willcodejavaforfood
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.
右键单击您的项目并选择 Build Path-Configure Build Path。这将打开一个带有四个选项卡的对话框,用于配置构建路径。如果您的属性文件已经在您的项目中,那么很可能已经在构建路径中,而您只是错误地引用了它。
回答by sergionni
resolved by specifying: classpathentry kind="lib" path="dbconfig.properties"
通过指定解决:classpathentry kind="lib" path="dbconfig.properties"