加载资源包:Spring

加载资源包:Spring,spring,resourcebundle,Spring,Resourcebundle,我正在尝试在春季使用ResourceBundleMessageSource。以下是我的项目结构: 下面是xml配置: <bean name="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>messages</value>

我正在尝试在春季使用ResourceBundleMessageSource。以下是我的项目结构:

下面是xml配置:

<bean name="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename">
        <value>messages</value>
    </property>
</bean>

如果我将我的资源包文件直接放在resources文件夹下,则不会出现此错误。它工作得很好。有人能告诉我如何通过将资源束放在src/main/resources的子目录中来完成这项工作吗?

您需要在此处指定文件夹名称-

<property name="basename">
      <value>resourceBundles/messages</value>
</property>

资源包/消息

请检查并告诉我,在部署应用程序的“类”文件夹中,您可以看到您创建的属性文件??请查看@Kshitij的答案。他是对的。:-)
<property name="basename">
      <value>resourceBundles/messages</value>
</property>