有时候,在SPRING中两个类互相含有对方的声明,一般情况这是不允许并且极可能是有错误的。
会报这个错:
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘***’: Bean with name ‘***’ has been injected into other beans [***, ***]in its raw version as part of a circular reference,

but has eventually been wrapped (for example as part of auto-proxy creation). 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 ‘getBeanNamesOfType’ with the ‘allowEagerInit’ flag turned off, for example.


但有时候这正是我们想要的,考虑这种情况:
我们用一个ManagerFactory来包含所有Manager的声明,以便在程序中用到多个Manager的地方,一个入口集中访问。但是,可能某个Manager本身就需要用到其它几个Manager,进而用到ManagerFactory。这时,我们可以这样声明即可:

 <bean />

 

来源:http://www.blogjava.net/alwayscy/archive/2008/02/24/181726.htm

 

 


 

相关文章:

  • 2020-01-13
  • 2021-12-28
  • 2022-02-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-12-23
  • 2021-06-26
  • 2021-07-04
  • 2021-12-31
相关资源
相似解决方案