在Eclipse中找不到文件

斯曼斯菲尔德

我有一个Eclipse JSF示例,其中ExampleController类找不到Bundle.properties文件。这是用于创建JSF项目的动态Web项目快照,

动态网络项目

这是项目文件结构的快照。您可以在properties文件夹中看到bundles文件,

项目文件结构

这是类代码的快照。注意getBundle方法中的文件名,

@ManagedBean(name = "exampleController")
@RequestScoped
public class ExampleController {
    private String exampleProperty;

    * Creates a new instance of ExampleController
    */
    public ExampleController() {
        exampleProperty = "Used to instantiate the bean.";
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, 
                        ResourceBundle.getBundle("WebContent/properties/Bundle.properties").getString("ExampleMessage"), null);
    FacesContext.getCurrentInstance().addMessage(null, facesMsg);
}

最后,这是我在tomcat服务器上运行代码时错误的快照,

运行时Tomcat服务器错误

我尝试了几种文件名组合,但是在服务器运行时继续出现找不到文件的错误。我想念什么?

最好的问候,史蒂夫·曼斯菲尔德

雅罗斯拉夫·扎鲁巴(JaroslavZáruba)

Try to play with the path. The "WebContent" in your path does not seem right. Usually the resource path gets resolved relatively to WEB-INF or current class-file location. You could also try to put your properties directory in several places, to see if it gets picked up in one of those. :)

Also if you could get your hands on where the built project is actually run from "physically" (if it is not from these very files) maybe you would find out the properties file does not get copied with your other files. (Do you have Deployment Assembly in your Project settings? If so, check it out.)

UPDATE: If you simply need to open a properties file, check this one out: getResourceAsStream() is always returning null ...I don't know if your folder is special in some way tho.

多数情况下,当Tomcat在Eclipse中开始出现异常行为时,我发现Deployment Assembly已完成。(发生在Mavenized项目中。看来Eclipse和m2eclipse并不是最好的朋友。)
这种情况适合这样的情况:“当部署到生产服务器时工作,而不是从Eclipse中运行时工作。”

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Eclipse找不到文件

来自分类Dev

Eclipse在文件夹中找不到我的项目

来自分类Dev

在Android Eclipse中找不到SDK文件夹

来自分类Dev

Eclipse / C ++找不到头文件

来自分类Dev

找不到头文件,Eclipse

来自分类Dev

在Django中找不到文件

来自分类Dev

在文件中找不到音乐!

来自分类Dev

在Java中找不到文件

来自分类Dev

Eclipse在res / layout文件夹中找不到android xml布局文件

来自分类Dev

Eclipse在Ubuntu 12中找不到JVM

来自分类Dev

在Eclipse中找不到android设备?

来自分类Dev

资源中的文件找不到本地文件

来自分类Dev

在android中写入文件,找不到文件

来自分类Dev

Maven / Eclipse:在类路径中找不到任何META-INF / persistence.xml文件

来自分类Dev

在OS X(C ++)中设置Eclipse错误:启动失败,找不到二进制文件?

来自分类Dev

尝试在Eclipse中运行Python脚本时出现“ NameError:找不到模块maya的文件”

来自分类Dev

Eclipse中的Scons插件找不到scons可执行文件

来自分类Dev

在OS X(C ++)中设置Eclipse错误:启动失败,找不到二进制文件?

来自分类Dev

.classpath / .settings 文件夹存在于 Eclipse 中,但我找不到它

来自分类Dev

在外部网址中找不到文件

来自分类Dev

Laravel在目录中找不到文件?

来自分类Dev

在Docker容器中找不到文件

来自分类Dev

在laravel 5.2的路径中找不到文件

来自分类Dev

在Xcode中找不到.pbxproj文件

来自分类Dev

在声明的路径中找不到文件

来自分类Dev

在Symfony中找不到字体文件的路由

来自分类Dev

在LibGDX中创建Pixmap找不到文件

来自分类Dev

在xcode 6中找不到'string'文件

来自分类Dev

在资源映射Xamarin中找不到文件

Related 相关文章

热门标签

归档