JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

springboot解决循环依赖

发布时间 2023-09-12 10:26:44作者: 種瓜得豆
import org.springframework.context.annotation.Lazy;

@Service
public class CService {

    private AService aService; // 去掉@Autowired
    
    // 采用构造器方式,加入Lazy注解
    public CService(@Lazy AService aService) { 
        this.aService = aService;
    }
}
    本栏目推荐文章
  • 蚂蚁爱购--靠谱的SpringBoot项目
  • 实时数据流无忧:用 SpringBoot 和 SSE 打造动态前端更新的终极指南
  • springBoot(基础部分)
  • SpringBoot配置报错:Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
  • 40 个 SpringBoot 常用注解:让生产力爆表!
  • Springboot 全局日期时间格式处理
  • SpringBoot中使用SpringEvent业务解耦神器实现监听发布事件同步异步执行任务
  • SpringBoot3.x升级整合各依赖
  • Springboot 项目集成 PageOffice V6 最简单代码
  • SpringBoot中使用SpringRetry实现重试机制(重试调用第三方API)
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们