Java NoSuchMessageException:在代码SpringBoot下未找到任何消息

Java NoSuchMessageException:在代码SpringBoot下未找到任何消息,java,spring-boot,Java,Spring Boot,我已经将内化功能添加到我的应用程序中,但是我仍然得到一个例外 这是我的配置文件,其中包含messageSource配置 @Configuration public class LocaleConfiguration implements WebMvcConfigurer { private static final Logger LOGGER = LoggerFactory.getLogger(LocaleConfiguration.class); /** * *

我已经将内化功能添加到我的应用程序中,但是我仍然得到一个例外

这是我的配置文件,其中包含messageSource配置

@Configuration
public class LocaleConfiguration implements WebMvcConfigurer {

    private static final Logger LOGGER = LoggerFactory.getLogger(LocaleConfiguration.class);

    /**
     * * @return default Locale set by the user
     */
    @Bean(name = "localeResolver")
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.ENGLISH);
        return slr;
    }

    /**
     * an interceptor bean that will switch to a new locale based on the value of the lang parameter appended to a request:
     *
     * @param registry
     * @language should be the name of the request param i.e  localhost:8010/api/get-all-exceptions/1?language=fr
     * <p>
     * Note: All requests to the backend needing Internalization should have the "language" request param
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
        localeChangeInterceptor.setParamName("language");
        registry.addInterceptor(localeChangeInterceptor);
    }

    @Bean("messageSource")
    public MessageSource messageSource() {
        ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource ();
        resourceBundleMessageSource.setBasename("i18n/messages");
        resourceBundleMessageSource.setDefaultEncoding("UTF-8");
        resourceBundleMessageSource.setFallbackToSystemLocale(true);
        return resourceBundleMessageSource;
    }
当我试图发布?language=en时,我得到以下错误:

org.springframework.context.NoSuchMessageException: No message found under code 'ERROR_FIND_TRANSCODIFICATION' for locale 'en'.
    at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:161)
    at fr.cnp.aec.commons.services.impls.LocaleServiceImpl.getMessage(LocaleServiceImpl.java:38)
我每次都会遇到这个错误,我已经检查过了,属性文件在那里\u en和\u fr

编辑:


message.properties中的代码错误

您可能有A)无效配置,或者B)在您的message\n文件下找不到变量“ERROR\u FIND\u transcodication”。谢谢你,苏珊,你说得对,我在代码的末尾有一个N缺失。我很确定我的留言没有问题。
org.springframework.context.NoSuchMessageException: No message found under code 'ERROR_FIND_TRANSCODIFICATION' for locale 'en'.
    at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:161)
    at fr.cnp.aec.commons.services.impls.LocaleServiceImpl.getMessage(LocaleServiceImpl.java:38)