标签:img auto spring ada qualifier conf lazy undle lte
spring boot国际化使ReloadableResourceBundleMessageSource设置basenames并返回messagesource
@Configuration public class I18nConfig { @Bean(name = "messageSource") public ReloadableResourceBundleMessageSource messageSource() { ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource(); messageBundle.setBasename("classpath:messages/messages"); messageBundle.setDefaultEncoding("UTF-8"); return messageBundle; } }
接着直接使用:
代码调用:
@Autowired @Qualifier("messageSource") private MessageSource messageSource; //下面在方法种使用 messageSource.getMessage("test", new Object[], SIMPLIFIED_CHINESE);
spring boot国际化类ReloadableResourceBundleMessageSource
标签:img auto spring ada qualifier conf lazy undle lte
原文地址:https://www.cnblogs.com/nizuimeiabc1/p/13060287.html