首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载资源包: Spring

加载资源包: Spring
EN

Stack Overflow用户
提问于 2012-06-07 17:31:16
回答 1查看 11.4K关注 0票数 2

我正在尝试在Spring中使用ResourceBundleMessageSource。下面是我的项目结构:

下面是xml配置:

代码语言:javascript
复制
<bean name="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename">
        <value>messages</value>
    </property>
</bean>

当我试图加载应用程序上下文时,我得到了以下异常:

代码语言:javascript
复制
Jun 7, 2012 2:44:00 PM org.springframework.context.support.ResourceBundleMessageSource getResourceBundle
WARNING: ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages, locale en_US
Exception in thread "main" org.springframework.context.NoSuchMessageException: No message found under code 'user.welcome' for locale 'en_US'.
    at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:135)
    at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1192)
    at com.pramati.core.MessageResolver.getMessage(MessageResolver.java:19)

如果我把我的资源包文件直接放在resources文件夹下,我不会得到这个错误。它工作得很好。有人能让我知道如何通过将资源包放在src/main/resources的子目录中来完成这项工作吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-07 17:34:34

您需要在此处提供文件夹名称-

代码语言:javascript
复制
<property name="basename">
      <value>resourceBundles/messages</value>
</property>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10929179

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档