Maison  >  Questions et réponses  >  le corps du texte

java - Spring service中怎么使用当前的service对象,Autowired不成功

比如AuthServiceImpl下有getUser()和getPage()两个方法,在getPage中我要调用getUser()方法,使用

@Autowired(required = false)

private AuthService authService;

自动注入会报错,在getPage里面new一个AuthService对象也不可以。

像这种service中使用当前对象应该怎么注入?

伊谢尔伦伊谢尔伦2742 Il y a quelques jours428

répondre à tous(2)je répondrai

  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:57:44

    this.getUser();

    répondre
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:57:44

    S'il n'y a pas de problème avec la configuration, vous pouvez considérer le problème de version

    répondre
    0
  • Annulerrépondre