Bootstrap

使用@Async后项目启动报错

最近在使用异步方法使用@Async项目怎么也启动不起来,最后看报错信息说是导致了循环依赖问题

报错信息如下

 has been injected into other beans [] in its raw version as 
part of a circular reference, but has eventually been wrapped. 
This means that said other beans do not use the final
 version of the bean.This is often the result of over-eager
 type matching - consider using 'getBeanNamesForType' with the 
'allowEagerInit' flag turned off, for example.

 方法

 @Async
    public void newsAsync(User user) {

    }

解决办法

使用@Lazy

   @Autowired
    @Lazy
    private UserService userService;

@Lazy的作用

1 延迟加载bean对象

2 解决循环依赖问题

;