zoukankan      html  css  js  c++  java
  • 项目报错This is often the result of over-eager type matching

      今天启动项目时报错:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'colorController': Unsatisfied dependency expressed through field 'jobService'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'jobService': Bean with name 'jobService' has been injected into other beans [ProcessService,ProcessManualService] 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.

    首先控制台是从一个controller报出的错

     跟踪发现

     于是去jobService中看看

     然后到这两个service中再看看,结果发现

    构成了循环引用,去掉没有使用的引用,问题解决!

    当然,如果你的系统过于庞大,不好找哪里构成了循环引用,可以使用spring提供的bean懒加载解决:

    @Autowired
    @Lazy
    private ClassA classA;
    @Autowired
    @Lazy
    private ClassB classB;

    不过解决循环依赖,当然最好的方法是重构你的代码,进行解耦。

  • 相关阅读:
    面向消息的持久通信与面向流的通信
    通信协议
    [1]序章,基本
    深拷贝和浅拷贝
    堆/栈 内存管理相关
    C++的四种cast(显示类型转换)
    智能指针相关
    C++对象模型:单继承,多继承,虚继承
    HTTP/TCP
    [读书笔记] 为什么绝不在构造/析构函数中调用virtual函数
  • 原文地址:https://www.cnblogs.com/guanghe/p/13926031.html
Copyright © 2011-2022 走看看