我正在尝试从jar文件加载message.properties文件,但它找不到该文件(我已经尝试了几个小时)。
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages/messages</value>
<value>classpath:org/common/messages/messages</value>
</list>
</property>
</bean>
但它无法找到它:
[org.springframework.context.support.ResourceBundleMessageSource] (http-/0:0:0:0:0:0:0:0:8080-5) ResourceBundle [classpath:org/common/messages/messages] not found for MessageSource: Can't find bundle for base name classpath:org/common/messages/messages, locale en_US
我已经尝试了以下内容,它确实加载了文件,我认为这意味着该文件位于类路径上
ClassPathResource cpr = new ClassPathResource("org/common/messages/messages.properties");
有什么区别?
我在JBoss上运行它。
答案 0 :(得分:2)
尝试此示例,来自此POST - Spring UTF-8 message resource from external jar proglem
<bean id="propertiesMessageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:com/mypackage/i18n/messages" />