Spring Cloud Bus with rabbit - 应用程序无法启动

Posted

技术标签:

【中文标题】Spring Cloud Bus with rabbit - 应用程序无法启动【英文标题】:Spring Cloud Bus with rabbit - Application Failed to Start 【发布时间】:2021-10-21 11:04:24 【问题描述】:

我正在尝试创建一个配置服务器来侦听 Git 事件并将事件流式传输到客户端。我遵循了几个示例和文档,但我无法启动应用程序。我想我的 spring boot 和 cloud 版本有问题。

重要的是要提到我用 docker 运行 rabbitmq。

这是我的 build.gradle

plugins 
    id 'org.springframework.boot' version '2.5.3'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'


group = 'com.pal.pocs.config'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations 
    compileOnly 
        extendsFrom annotationProcessor
    


repositories 
    mavenCentral()


ext 
    set('springCloudVersion', "2020.0.3")


dependencies 
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.cloud:spring-cloud-config-server'
    implementation 'org.springframework.cloud:spring-cloud-starter-bus-amqp'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'


dependencyManagement 
    imports 
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
    


test 
    useJUnitPlatform()

这是我得到的例外:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.stream.binder.rabbit.RabbitMessageChannelBinder.createConsumerEndpoint(RabbitMessageChannelBinder.java:517)

The following method did not exist:

    org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter.<init>(Lorg/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer;)V

The method's class, org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter, is available from the following locations:

    jar:file:/C:/Users/lambe/.gradle/caches/modules-2/files-2.1/org.springframework.integration/spring-integration-amqp/5.5.2/7195ed265b0f6c24e52c3ed84253f7974b2d5014/spring-integration-amqp-5.5.2.jar!/org/springframework/integration/amqp/inbound/AmqpInboundChannelAdapter.class

The class hierarchy was loaded from the following locations:

    org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter: file:/C:/Users/lambe/.gradle/caches/modules-2/files-2.1/org.springframework.integration/spring-integration-amqp/5.5.2/7195ed265b0f6c24e52c3ed84253f7974b2d5014/spring-integration-amqp-5.5.2.jar
    org.springframework.integration.endpoint.MessageProducerSupport: file:/C:/Users/lambe/.gradle/caches/modules-2/files-2.1/org.springframework.integration/spring-integration-core/5.5.2/d6822cb2d758d2a5d821879778c31120b4a3c86c/spring-integration-core-5.5.2.jar
    org.springframework.integration.endpoint.AbstractEndpoint: file:/C:/Users/lambe/.gradle/caches/modules-2/files-2.1/org.springframework.integration/spring-integration-core/5.5.2/d6822cb2d758d2a5d821879778c31120b4a3c86c/spring-integration-core-5.5.2.jar
    org.springframework.integration.context.IntegrationObjectSupport: file:/C:/Users/lambe/.gradle/caches/modules-2/files-2.1/org.springframework.integration/spring-integration-core/5.5.2/d6822cb2d758d2a5d821879778c31120b4a3c86c/spring-integration-core-5.5.2.jar
2

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter

有人知道错误配置在哪里吗?

【问题讨论】:

【参考方案1】:

好吧,我想通了

我发现 Spring Boot 2.4.6 支持 Spring Cloud 2020.0.3

所以我降级到 2.4.6 并启动应用程序!

希望对其他人有帮助

【讨论】:

以上是关于Spring Cloud Bus with rabbit - 应用程序无法启动的主要内容,如果未能解决你的问题,请参考以下文章

Spring Cloud Bus with rabbit - 应用程序无法启动

问题 spring-cloud-config 和 spring-cloud-bus

Spring Cloud学习记录 08Spring Cloud Bus服务总线

spring cloud-stream 和 spring cloud-bus 有啥区别?

为 spring-cloud-bus 设置 zookeeper 主机和端口

Spring Cloud Bus与Consul