gpt4 book ai didi

java - .MissingResourceException : Can't find bundle for base name

转载 作者:搜寻专家 更新时间:2023-11-01 01:34:44 25 4
gpt4 key购买 nike

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

当它被导入到 IntellijIDea 中的新项目时,它就可以工作了。

JNCA

我敢打赌,当它在 Maven 项目中使用时,它不起作用并给出此异常。

jnca

异常(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()));
}

我的名字 = Netflow

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

如何解决这个问题

谢谢

最佳答案

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

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

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

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

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

那么 PanneauPrincipal_en.properties 文件应该位于以下目录中:

    src/main/resources/i18n

关于java - .MissingResourceException : Can't find bundle for base name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21903691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com