当我尝试在@Controller类中获取消息时,一切正常,但是当我尝试时
要在@Service或@Component类中实现相同,我收到以下错误:
org.springframework.context.NoSuchMessageException: No message found under code 'email.ativacao.Title' for locale 'pt_BR'.
我的控制器:
@Controllerpublic class TestController { @autowired TestService service; @autowired TestComponent component; @autowired private MessageSource message; @RequestMapPing(value = "/send",method = RequestMethod.GET) public String go() { String message = message.getMessage ("email.ativacao.Title",null,new Locale("pt","BR")); service.getMessage(); component.getMessage(); return "signsucess"; }}
我的服务:
@Servicepublic class TestService { @autowired private MessageSource message; public voID getMessage() { //Error String message = message. getMessage("email.ativacao.Title","BR")); }}
我的组件:
@Componentpublic class TestComponent { @autowired private MessageSource message; public voID getMessage() { //Error String message = message. getMessage("email.ativacao.Title","BR")); }}
我的配置:
java– 在上下文创建开始时运行
上一篇
2022-06-08
java–Inject不适用于new运算符
下一篇
2022-06-08
评论列表(0条)