1、问题描述
Spring Boot 项目加入了 Amqp 依赖,但是未暂未使用消息队列,而又由于开启了 Acuator 监控暴露所有端点(因为暴露了 amqp,因此也需要检查 amqp),导致项目启动出现这个报错(虽然不影响,但是强迫症看着不舒服)
2、3 种解决办法
- 方式 1:注释掉 pom 或者 build.gradle 中暂时不用的 amqp 依赖
// implementation group: 'org.springframework.boot', name: 'spring-boot-starter-amqp', version: '2.1.4.RELEASE'
- 方式 2:在启动类上排除 Amqp 的自动装配
@SpringBootApplication(exclude = {RabbitAutoConfiguration.class})
public class BossApplication {
public static void main(String[] args) {
SpringApplication.run(BossApplication.class, args);
}
}
- 方式 3:关闭暴露端点 Amqp 的信息
management.health.rabbit = false
或
management:
health:
enabled: true
show-details: always #总是显示详细信息。可显示每个模块的状态信息
rabbit:
enabled: false