如果将
RepositoryRestMvcConfiguration
,重写并复制其方法
resourceDescriptionMessageSourceAccessor
,但已设置
fallbackToSystemLocale
到
false
对于
messageSource
?
@Override
@Bean
public MessageSourceAccessor resourceDescriptionMessageSourceAccessor() {
try {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("rest-default-messages.properties"));
propertiesFactoryBean.afterPropertiesSet();
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:rest-messages");
messageSource.setCommonMessages(propertiesFactoryBean.getObject());
messageSource.setDefaultEncoding("UTF-8");
// Adding this line:
messageSource.setFallbackToSystemLocale(false);
return new MessageSourceAccessor(messageSource);
} catch (Exception o_O) {
throw new BeanCreationException("resourceDescriptionMessageSourceAccessor", "", o_O);
}
}
如果您创建
rest-default-messages.properties
具有默认语言环境?值的文件?。。
问题作者更新
保护春天。数据其余。*属性创建
RepositoryRestConfiguration
如下面所述的Bean
post
:
@Bean
@ConfigurationProperties(prefix = "spring.data.rest")
@Override
public RepositoryRestConfiguration config() {
return super.config();
}