[英]spring-boot: ResourceBundle with external messages.properties file
@Configuration
public class MessageSourceConfig {
@Bean
public static MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("file: c:/temp/messages");
return messageSource;
}
}
I am trying to make spring-boot to use my external messages.properties, messages_en_Us.properties files. 我正在尝试使spring-boot使用我的外部messages.properties,messages_en_Us.properties文件。 Unfortunately I get this error: 不幸的是我得到这个错误:
ResourceBundle [file: c:/temp/messages] not found for MessageSource: Can't find bundle for base name file: c:/temp/messages, locale en_US
Files are there and I have studied such cases and it is stated that this should work in spring-boot, but it doesn't. 文件已经存在,我已经研究了这种情况,并指出这应该在spring-boot中起作用,但事实并非如此。 I have also tried ReloadableResourceBundleMessageSource
and failed the same way. 我也尝试过ReloadableResourceBundleMessageSource
并以相同的方式失败。 What am I doing wrong here? 我在这里做错了什么?
Try that : 尝试:
messageSource.setBasename("file://c:/temp/messages");
Edit : 编辑:
After some tests in comments, it is rather this way of doing which works for the OP : 经过评论中的一些测试之后,OP才可以使用这种方法:
messageSource.setBasename("file:C:/temp/messages");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.