springboot普通类中获取i18对应的值

@Autowired
//所有i18配置文件键值转换通过它实现
MessageSource messageSource;

//LocaleContextHolder.getLocale()获取当前请求的locale,详情查看MessageSource 这个类
messageSource.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", null, LocaleContextHolder.getLocale());
原文地址:https://www.cnblogs.com/zhouquan-1992-04-06/p/12829743.html