简体   繁体   English

由 Spring Boot 中的 :org.springframework.context.NoSuchMessageException 引用

[英]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.

相关问题 ReloadableResourceBundleMessageSource:org.springframework.context.NoSuchMessageException - ReloadableResourceBundleMessageSource: org.springframework.context.NoSuchMessageException 异常类名称:org.springframework.context.NoSuchMessageException - Exception Class Name: org.springframework.context.NoSuchMessageException Spring Boot 2.0.1中的NoSuchMessageException - NoSuchMessageException in Spring boot 2.0.1 Spring Boot中带有MessageSource的NoSuchMessageException - NoSuchMessageException with MessageSource in Spring Boot 无法实例化接口 org.springframework.context.ApplicationContextInitializer (Spring 5.2.3 + Spring Boot 2.2.3) - Cannot instantiate interface org.springframework.context.ApplicationContextInitializer (Spring 5.2.3 + Spring Boot 2.2.3) org.springframework.boot.context.event.ApplicationFailedEvent无法转换为org.springframework.boot.web.context.WebServerInitializedEvent - org.springframework.boot.context.event.ApplicationFailedEvent cannot be cast to org.springframework.boot.web.context.WebServerInitializedEvent Spring Boot:SpringApplication.run导致org.springframework.context.ApplicationContextException: - Spring Boot: SpringApplication.run causes org.springframework.context.ApplicationContextException: 当我在Eclipse中将应用程序作为Spring引导应用程序运行时,它抛出org.springframework.context.ApplicationContextException吗? - When I run my app as Spring boot app at Eclipse, it throw org.springframework.context.ApplicationContextException? 从 spring boot 2.6.2 迁移到 2.6.6 后,得到 org.springframework.context.ApplicationContextException - After Migrating from spring boot 2.6.2 to 2.6.6 , getting org.springframework.context.ApplicationContextException 运行 spring boot 应用程序错误:无法实例化接口 org.springframework.context.ApplicationListener - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM