我只要在directoryProcurementApplyServiceImpl这个类中的一个方法上加上@Async,启动就报错。
The dependencies of some of the beans in the application context form a cycle:
| ESInitController (field private com.zhichubao.core.service.p2p.payables.PayablesService com.zhichubao.web.api.ESInitController.payablesService)
↑ ↓
| payablesServiceImpl (field private com.zhichubao.core.service.common.CommonService com.zhichubao.core.service.p2p.payables.impl.PayablesServiceImpl.commonService)
↑ ↓
| commonServiceImpl (field private com.zhichubao.core.service.p2p.procurement.DirectoryProcurementApplyService com.zhichubao.core.service.common.impl.CommonServiceImpl.directoryProcurementApplyService)
↑ ↓
| directoryProcurementApplyServiceImpl
└─────┘
但是我在controller中用过异步注解很多次都没报错,放到service上的方法上就报错,什么原因呢?
在你循环依赖的两个bean的任意一个上加上lazy-init属性试试。
例如: