1.  xml配置

     

  2. 两个类实现统同一个接口的同一个方法时的注解使用及bean配置


  3. 代码:

  4. @Service  
  5. public class AaaService implements IChangePassword {  
  6.   
  7.     @Override  
  8.     public void changePassword(String username, String password) {  
  9.     }  
  10.   
  11. }  
  12.   
  13. @Service  
  14. public class BbbService implements IChangePassword {  
  15.   
  16.     @Override  
  17.     public void changePassword(String username, String password) {  
  18.     }  
  19.   
  20. }  
  21.   //第一种
  22. public class AccountController extends BaseController {  
  23.     @Autowired  
  24.     @Qualifier("aaaService")  
  25.     private IChangePassword aaaService;  
  26.   
  27.         @Autowired  
  28.     @Qualifier("bbbService")  
  29.     private IChangePassword bbbService;  }

  30. //第二种
    1. public class AccountController2 extends BaseController {  
    2.     @Resource("aaaService")  
    3.     private IChangePassword aaaService;          
                @Resource("bbbService")  
  31.     private IChangePassword bbbService;  }
两个类实现统同一个接口的同一个方法时的注解使用及bean配置

相关文章:

  • 2021-09-06
  • 2022-12-23
  • 2021-08-20
  • 2022-02-02
  • 2021-11-20
  • 2022-02-02
  • 2022-12-23
  • 2021-08-16
猜你喜欢
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案