Spring Boot在RabbitMQ上的自动配置启动失败

3
我有一个大的Spring Boot应用程序,其中使用了RabbitMQ等技术。 我为Rabbit队列创建了一个@Configuration文件。这在Spring Boot 1.0.2上运行良好。今天我升级到版本1.1.0,现在启动时出现异常。
问题似乎是HealthIndicator会检测到RabbitMQ可用,并尝试设置其健康指标。然后它无法注入rabbitTemplate并立即失败。错误消息的一部分是:“Error creating bean with name 'rabbitTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?”
下面是实际的异常跟踪。
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'environmentMvcEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.boot.actuate.endpoint.EnvironmentEndpoint]: : Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration.rabbitTemplates; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cisco.config.queuing.QueuingConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.amqp.rabbit.core.RabbitTemplate com.cisco.config.queuing.QueuingConfiguration.rabbitTemplate; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rabbitTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration.rabbitTemplates; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cisco.config.queuing.QueuingConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.amqp.rabbit.core.RabbitTemplate com.cisco.config.queuing.QueuingConfiguration.rabbitTemplate; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rabbitTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:747) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:462) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:470) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:459) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1063) ~[spring-context-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints.afterPropertiesSet(MvcEndpoints.java:55) ~[spring-boot-actuator-1.1.0.RELEASE.jar!/:1.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
... 92 common frames omitted

1
你能发布你的Spring配置XML吗? - fmodos
1个回答

4
这看起来像是Spring Boot中新的健康指标存在的一个bug。我已经在https://github.com/spring-projects/spring-boot/issues/1081上提出了问题。
在问题得到解决之前,你可以通过在你的application.properties中设置health.rabbit.enabled=false来禁用rabbit的HealthIndicatorAutoConfiguration

@Larry13767,你能提供一个示例项目并对问题#1081发表一些评论吗? - Phil Webb
当然,我现在的项目时间很紧,但如果这个周末可以的话,我应该能够完成它。 - EvilJinious1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接