使用@Autowired在spring中使用循环依赖

时间:2015-04-28 03:51:33

标签: spring circular-dependency

我在春天一直面临着循环依赖的问题。

Public class UserServiceImpl implements UserService{
   @Autowired
   private RoleService roleService;
}

Public class RoleServiceImpl implements RoleService{
   @Autowired
   private UserService userService;
}

有没有解决这个问题的方法,但我仍然想使用@Autowired。其他解决方案可能是手动连接它们。或者通过使用bean感知或使用bean post processor。

1 个答案:

答案 0 :(得分:0)

  

工作解决方案是添加default-lazy-init =" true"到了   application config xml file

详情为here

相关问题