springboot解决循环依赖

import org.springframework.context.annotation.Lazy;

@Service
public class CService {

    private AService aService; // 去掉@Autowired
    
    // 采用构造器方式,加入Lazy注解
    public CService(@Lazy AService aService) { 
        this.aService = aService;
    }
}
posted @ 2023-09-12 10:24  種瓜得豆  阅读(199)  评论(0编辑  收藏  举报