有時候,在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.
<bean id=".******"" class="com..******".web.business.activity.service.impl.******" lazy-init="true"/>