Coused by :org.springframework.context.NoSuchMessageExceptio



我有一个Spring引导Maven项目,我试图捕获IO异常,但我得到了以下错误:

org.springframework.context.NoSuchMessageException: No message found under code 'inventory.error' for locale 'de_DE'.

我的方法:

@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";
}

我想这是因为我的windows语言是德语。如何将异常的语言更改为英语?

由于找不到属性文件,基于属性文件结构,application.yml应该像spring.messages.basename:yourProjectDirectory/messages/messages

最新更新