简体   繁体   English

.MissingResourceException:找不到基本名称的包

[英].MissingResourceException: Can't find bundle for base name

I'm using library called jnca to capture netflow udp packets sent from a router. 我正在使用名为jnca的库来捕获从路由器发送的netflow udp数据包。

When it's imported in to a new project in IntellijIDea it works. 当它被导入到IntellijIDea中的新项目时,它可以工作。

JNCA

Bet when that is used inside a maven project it doesn't work and gives this exception. 在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

There is no package naming issues. 没有包命名问题。

Problem is with this code segment 问题在于此代码段

      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

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 并尝试将该netflow.properties文件包含在maven项目的资源文件夹中,它也无法正常工作

How to fix this 如何解决这个问题

Thank you 谢谢

When using Maven, properties files should be located inside src/main/resources not in src/main/java (see here ) 使用Maven时,属性文件应位于src / main / resources中,而不是src / main / java中(参见此处

So, for instance, if you have the following definition in your faces-config.xml (for using the msgs variable in your facelet pages) : 因此,例如,如果faces-config.xml中有以下定义(用于在facelet页面中使用msgs变量):

    <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);

Then the PanneauPrincipal_en.properties file should be located in the following directory : 然后PanneauPrincipal_en.properties文件应位于以下目录中:

    src/main/resources/i18n

Copy your .properties files to the resources folder in the root (not inside packages) And then in your code when you want to access these .properties files don't mention any package name. 将.properties文件复制到根目录中的resources文件夹(不在包内)然后在您的代码中,当您要访问这些.properties文件时,不要提及任何包名称。 just only the name of the .properties files in enough. 只有.properties文件的名称就足够了。 like this: 像这样:

 resources = ResourceBundle.getBundle(myName, Locale.getDefault());

暂无
暂无

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

相关问题 MissingResourceException - 找不到基本名称的包 - MissingResourceException - Can't find bundle for base name MissingResourceException:找不到基本名称的捆绑 - MissingResourceException: Can't find bundle for base name MissingResourceException:找不到基本名称的捆绑 - MissingResourceException: Can't find bundle for base name java.util.MissingResourceException:找不到基本名称的包 - java.util.MissingResourceException: Can't find bundle for base name MissingResourceException:运行 JAR 时找不到基本名称的捆绑包 - MissingResourceException: Can't find bundle for base name when running JAR java.util.MissingResourceException:找不到基本名称的包 - java.util.MissingResourceException: Can't find bundle for base name java.util.MissingResourceException:找不到基本名称包的包 - java.util.MissingResourceException: Can't find bundle for base name Bundle java.util.MissingResourceException:找不到基本名称为ResBundle的包,语言环境为en_GB - java.util.MissingResourceException: Can't find bundle for base name ResBundle, locale en_GB java.util.MissingResourceException:找不到基本名称消息的bundle,locale en_US - java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US MissingResourceException:找不到基本名称资源的捆绑包。controls.controls_res,语言环境 - MissingResourceException: Can't find bundle for base name resources.controls.controls_res, locale en
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM