Java Code Examples for org.springframework.context.support.ReloadableResourceBundleMessageSource#setUseCodeAsDefaultMessage()

The following examples show how to use org.springframework.context.support.ReloadableResourceBundleMessageSource#setUseCodeAsDefaultMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HibernateValidateConfig.java    From spring-boot-api-project-seed with Apache License 2.0 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource = new ReloadableResourceBundleMessageSource();
    reloadableResourceBundleMessageSource.setBasenames("classpath:message/ValidationMessages");
    reloadableResourceBundleMessageSource.setUseCodeAsDefaultMessage(true);
    reloadableResourceBundleMessageSource.setDefaultEncoding("UTF-8");
    reloadableResourceBundleMessageSource.setCacheSeconds(60);
    return reloadableResourceBundleMessageSource;
}
 
Example 2
Source File: AppConfiguration.java    From SMSC with Apache License 2.0 5 votes vote down vote up
@Primary
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource messageSource() { // @todo not working
    ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource();
    messageBundle.setBasename("classpath:messages");
    messageBundle.addBasenames("classpath:messages", "classpath:validation");
    messageBundle.setUseCodeAsDefaultMessage(true);
    messageBundle.setDefaultEncoding("UTF-8");
    messageBundle.setFallbackToSystemLocale(true);

    return messageBundle;
}
 
Example 3
Source File: MvcAutoConfiguration.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * 消息处理,可以直接使用properties的key值,返回的是对应的value值
 * messageSource .
 * @return messageSource
 */
@Bean (name = "messageSource")
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource(
        @Value("${spring.messages.basename:classpath:messages/message}")
        String messagesBasename)  {
    _logger.debug("Basename " + messagesBasename);
    
    ReloadableResourceBundleMessageSource messageSource = 
            new ReloadableResourceBundleMessageSource();
    messageSource.setBasename(messagesBasename);
    messageSource.setUseCodeAsDefaultMessage(false);
    return messageSource;
}
 
Example 4
Source File: SpringMessageSourceHelperTest.java    From trimou with Apache License 2.0 5 votes vote down vote up
private static MessageSource initMessageSource() {
    final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setCacheSeconds(5);
    messageSource.setDefaultEncoding("UTF-8");
    messageSource.setFallbackToSystemLocale(true);
    messageSource.setUseCodeAsDefaultMessage(false);
    messageSource.setBasename("classpath:messages");
    return messageSource;
}