[英]Coused by :org.springframework.context.NoSuchMessageException in Spring Boot
I have a Spring boot Maven Project and I'm trying to catch an IO Exception and I get this error:我有一个 Spring Boot Maven 项目,我正在尝试捕获 IO 异常,但出现此错误:
org.springframework.context.NoSuchMessageException: No message found under code 'inventory.error' for locale 'de_DE'.
My method:我的方法:
@PostMapping("/inventory")
public String inventory(@ModelAttribute("Inventory") Inventory inventory, BindingResult bindingResult) {
try {
testBuildMdb();
} catch (Exception e) {
bindingResult.rejectValue("error", null, e.getMessage());
}
if (bindingResult.hasErrors()) {
return "inventory";
}
return "success";
}
I think this is because my windows language is German.我认为这是因为我的 Windows 语言是德语。 How can I change my exception's language to English?如何将例外的语言更改为英语?
这是由于找不到属性文件,基于属性文件结构,application.yml 应该像 spring.messages.basename: yourProjectDirectory/messages/messages
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.