.MissingResourceException: 找不到基本名称的包 [英] .MissingResourceException: Can't find bundle for base name

查看:73
本文介绍了.MissingResourceException: 找不到基本名称的包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用名为 jnca 的库来捕获从路由器发送的 netflow udp 数据包.

I'm using library called jnca to capture netflow udp packets sent from a router.

当它导入到 IntellijIDea 中的新项目时,它可以工作.

When it's imported in to a new project in IntellijIDea it works.

打赌在 maven 项目中使用它时它不起作用并给出此异常.

Bet when that is used inside a maven project it doesn't work and gives this exception.

异常:

java.util.MissingResourceException: Can't find bundle for base name org.wso2.event.adaptor.udp.jnca.etc.NetFlow, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:795)
at org.wso2.event.adaptor.udp.jnca.cai.utils.Resources.<init>(Resources.java:24)
at org.wso2.event.adaptor.udp.jnca.cai.flow.collector.Collector.<clinit>(Collector.java:51)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.wso2.event.adaptor.udp.jnca.cai.flow.collector.Run.<clinit>(Run.java:14)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
NetFlow.properties: Can't find bundle for base name org.wso2.event.adaptor.udp.jnca.etc.NetFlow, locale en_US

没有包命名问题.

这个代码段有问题

      try {

        resources = ResourceBundle.getBundle("org.wso2.event.adaptor.udp.jnca.etc." + myName, Locale
                                             .getDefault());
    } catch (MissingResourceException exc) {
        exc.printStackTrace();
        error(SuperString.exceptionMsg(exc.toString()));
    }

myName = Netflow

myName = Netflow

我尝试更改资源的路径,但没有成功.并尝试将该 netflow.properties 文件包含在 Maven 项目的资源文件夹中,但它也不起作用

I have tried changing the path to the resource but it didn't work. And tried to include that netflow.properties file inside the maven project's resources folder it also didn't work

如何解决这个问题

谢谢

推荐答案

当使用 Maven 时,属性文件应该位于 src/main/resources 中,而不是 src/main/java 中(参见 这里)

When using Maven, properties files should be located inside src/main/resources not in src/main/java (see here)

因此,例如,如果您的 faces-config.xml 中有以下定义(用于在您的 facelet 页面中使用 msgs 变量):

So, for instance, if you have the following definition in your faces-config.xml (for using the msgs variable in your facelet pages) :

    <resource-bundle>
        <base-name>i18n.PanneauPrincipal</base-name>
        <var>msgs</var>
    </resource-bundle>

或者如果您以编程方式加载资源文件:

Or if you load the resource files programmatically :

    ResourceBundle bundle = ResourceBundle.getBundle("i18n.PanneauPrincipal", locale);

然后 PanneauPrincipal_en.properties 文件应位于以下目录中:

Then the PanneauPrincipal_en.properties file should be located in the following directory :

    src/main/resources/i18n

这篇关于.MissingResourceException: 找不到基本名称的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆