springboot整合rabbitmq与actuator出现bug

bug: circular reference creating RabbitHealthIndicator

使用@Autowire 注入 rabbitTemplate时出现

@kitonGao Unrelated, closed issues are not a good place to ask for some help. Both Stack Overflow and Gitter are better places to ask. With that said, your problem is that you are trying to autowire dependencies into the fields of the configuration class that defines those dependencies. As a result, when RabbitMqConfig tries to define your RabbitTemplate bean the connectionFactory field is null. You need to separate the definition and consumption of the beans. There are a few ways to do that including splitting things out into separate classes or injecting dependencies into the @Bean methods rather than the class’s fields. If you need any further pointers, please follow up on Stack Overflow or Gitter.

解决思路将其作为参数注入
但是在@PostConstrutor 不能有参数

最终方案

    @Bean
    ApplicationRunner rabbitRunner(RabbitTemplate rabbitTemplate) {
        return args -> initRabbitTemplate(rabbitTemplate);
    }

Reference:
https://github.com/spring-projects/spring-boot/issues/1081

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值