过度的类型匹配的结果-考虑在关闭“ allowEagerInit”标志的情况下使用“ getBeanNamesOfType”

skd*_*skd 6 aop caching transactions spring-annotations

org.springframework.beans.factory.BeanCurrentlyInCreationException:创建名称为“ org.springframework.cache.annotation.AnnotationCacheOperationSource#0”的bean时出错:名称为“ org.springframework.cache.annotation.AnnotationCacheOperationSource#0”的bean已注入其他对象原始版本中的bean [org.springframework.cache.config.internalCacheAdvisor]作为循环引用的一部分,但最终被包装了。这意味着所说的其他bean不使用该bean的最终版本。这通常是由于过度渴望类型匹配而导致的-例如,考虑在关闭“ allowEagerInit”标志的情况下使用“ getBeanNamesOfType”。在org.springframework的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)处。向类org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCurrentlyInCreationException的上下文实例发送上下文初始化事件的异常:创建名称为“ org.springframework.cache.annotation.AnnotationCacheOperationSource#0”的bean时出错:作为循环引用的一部分,已将名称“ org.springframework.cache.annotation.AnnotationCacheOperationSource#0”以其原始版本注入到其他bean [org.springframework.cache.config.internalCacheAdvisor]中,但最终被包装了。这意味着所说的其他bean不使用该bean的最终版本。这通常是由于过度渴望类型匹配而导致的-例如,考虑在关闭“ allowEagerInit”标志的情况下使用“ getBeanNamesOfType”。在org.springframework.beans.factory。

">
Run Code Online (Sandbox Code Playgroud)

我的application-context.xml

<context:annotation-config />
<!-- Scans within the base package of the application for @Components to 
    configure as beans -->
<context:component-scan base-package="com.voterite.service" />

<aop:aspectj-autoproxy />

<cache:annotation-driven cache-manager="cacheManager" />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
    <property name="cacheManager" ref="ehcache" />
</bean>
<!-- Ehcache library setup -->
<bean id="ehcache"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation" value="/WEB-INF/ehcache/ehcache.xml" />
</bean>
Run Code Online (Sandbox Code Playgroud)

我正在使用@cachable和aop注释如何去掉BeanCurrentlyInCreationException:请帮助

Ole*_*syn 9

@Lazy在Validator类中为字段添加了注释:

@Autowired
@Lazy
private Service service;
Run Code Online (Sandbox Code Playgroud)

当遇到org.springframework.beans.factory.BeanCurrentlyInCreationException时:

“创建名称为'Service'的bean时出错:名称为'Service'的bean已被注入其他bean [Validator] ...”

“过度渴望的类型匹配的结果-考虑在关闭allowEagerInit标志的情况下使用getBeanNamesOfType”


小智 1

default-lazy-init="true"在您的 中使用applicationContext.xml,但这只是在开发期间。

对于暂存或测试构建,我们必须删除它,因为它会捕获所有初始 bean 错误。

我发现我的机器出现异常,而不是同事的机器,这就是我使用它并恢复工作的原因。

例如在顶部使用beans default-lazy-init="true" xmlns= your xmlns