在Mac OS上运行时的Spring循环引用

时间:2018-11-06 16:42:26

标签: java spring macos maven

我一直在Windows机器上使用Spring 4.0.7版的Java应用程序进行工作,该机器在过去几年中运行良好。最近,我们要求开发人员使用MacBook Pro进行开发,并且在运行应用程序时,我们在Spring配置中立即遇到了循环引用方面的问题(使用Maven构建是可以的)。有谁知道在Windows计算机上运行Spring应用程序与Mac OS计算机有什么不同的任何原因吗?

我们使用的Java版本是1.7.0.80, 例外的详细信息:

Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'reactor': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:334)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:446)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:420)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:545)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:155)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:305)
... 127 more

1 个答案:

答案 0 :(得分:0)

先检查一下:http://forum.spring.io/forum/spring-projects/container/115998-circular-dependency-identification-inconsistent

显然,在某些情况下,用于列出文件的基础OS api返回不同的顺序。

但是,您可以尝试通过更改要在@ComponentScan()批注中扫描的程序包的顺序或在触发异常的类上使用@dependsOn("reactor")批注来解决问题。< / p>