gpt4 book ai didi

caching - 过度类型匹配的结果 - 考虑使用 'getBeanNamesOfType' 并关闭 'allowEagerInit' 标志

转载 作者:行者123 更新时间:2023-12-04 14:01:46 25 4
gpt4 key购买 nike

org.springframework.beans.factory.BeanCurrentlyInCreationException:Error creating bean with name'org.springframework.cache.annotation.AnnotationCacheOperationSource#0':Bean with name'org.springframework.cache.annotation.AnnotationCacheOperationSource#0'has been injected into other beans[org.springframework.cache.config.internalCacheAdvisor] in its rawversion as part of a circular reference, but has eventually beenwrapped. This means that said other beans do not use the final versionof the bean. This is often the result of over-eager type matching -consider using 'getBeanNamesOfType' with the 'allowEagerInit' flagturned off, for example. atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1366)at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1454)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)atorg.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1379)atorg.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)atorg.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)atorg.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)at java.lang.Thread.run(Thread.java:619) 27 Aug, 2013 8:33:09 AMorg.apache.catalina.core.StandardContext listenerStart SEVERE:Exception sending context initialized event to listener instance ofclass org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCurrentlyInCreationException:Error creating bean with name'org.springframework.cache.annotation.AnnotationCacheOperationSource#0':Bean with name'org.springframework.cache.annotation.AnnotationCacheOperationSource#0'has been injected into other beans[org.springframework.cache.config.internalCacheAdvisor] in its rawversion as part of a circular reference, but has eventually beenwrapped. This means that said other beans do not use the final versionof the bean. This is often the result of over-eager type matching -consider using 'getBeanNamesOfType' with the 'allowEagerInit' flagturned off, for example. atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1366)at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1454)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)atorg.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1379)atorg.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)atorg.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)atorg.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)at java.lang.Thread.run(Thread.java:619)


我的应用程序context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans default-lazy-init="true">
<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>
</beans>
我正在使用 @cachable 和 aop 注释
如何爱 BeanCurrentlyInCreationException :
请帮忙

最佳答案

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

@Autowired
@Lazy
private Service service;

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

"Error creating bean with name 'Service': Bean with name 'Service' has been injected into other beans [Validator]... "

"result of over-eager type matching - consider using getBeanNamesOfType with the allowEagerInit flag turned off"

关于caching - 过度类型匹配的结果 - 考虑使用 'getBeanNamesOfType' 并关闭 'allowEagerInit' 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18461086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com