当前位置: 首页 > 知识库问答 >
问题:

春云流3.0应用多豆启动失败

艾雪风
2023-03-14

我是Spring云流的新手。我正在使用兔子MQ粘合剂。问题是当我在主类中使用单个 bean 启动应用程序时,它就成功启动了。但是,如果我在主类中注册了 1 个以上的 bean,则应用程序无法从以下日志启动。

2020-09-18 12:41:45.698  INFO 27416 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-18 12:41:45.706  INFO 27416 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-18 12:41:45.712  INFO 27416 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-18 12:41:45.730  INFO 27416 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-18 12:41:45.732  INFO 27416 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-18 12:41:46.371  INFO 27416 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
2020-09-18 12:41:46.384  INFO 27416 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function '' with acceptedOutputTypes: []
2020-09-18 12:41:46.627  INFO 27416 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel errorChannel
2020-09-18 12:41:46.722  INFO 27416 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel nullChannel
2020-09-18 12:41:46.756  INFO 27416 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageHandler errorLogger
2020-09-18 12:41:46.791  INFO 27416 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2020-09-18 12:41:46.791  INFO 27416 --- [           main] o.s.i.channel.PublishSubscribeChannel    : Channel 'application.errorChannel' has 1 subscriber(s).
2020-09-18 12:41:46.791  INFO 27416 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : started bean '_org.springframework.integration.errorLogger'
2020-09-18 12:41:46.804  INFO 27416 --- [           main] com.***.RabbitMQTest             : Started RabbitMQTest in 2.441 seconds (JVM running for 4.047)
2020-09-18 12:41:46.814  INFO 27416 --- [extShutdownHook] o.s.i.endpoint.EventDrivenConsumer       : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2020-09-18 12:41:46.815  INFO 27416 --- [extShutdownHook] o.s.i.channel.PublishSubscribeChannel    : Channel 'application.errorChannel' has 0 subscriber(s).
2020-09-18 12:41:46.815  INFO 27416 --- [extShutdownHook] o.s.i.endpoint.EventDrivenConsumer       : stopped bean '_org.springframework.integration.errorLogger'
2020-09-18 12:41:46.817  INFO 27416 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
2020-09-18 12:41:46.822  INFO 27416 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: bean 'errorChannel'
2020-09-18 12:41:46.823  INFO 27416 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: nullChannel
2020-09-18 12:41:46.823  INFO 27416 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: bean '_org.springframework.integration.errorLogger.handler' for component '_org.springframework.integration.errorLogger'
`

 @SpringBootApplication
 public class RabbitMQTest {

    public static void main(String[] args) {
        SpringApplication.run(RabbitMQTest.class, args);
    }

    @Bean
    public Function<String, String> toUpperCase() {
        return value -> {
            return value.toUpperCase();
        };
    }

    @Bean
    public Consumer<String> reverse() {
       return value -> new StringBuilder(value).reverse().toString();
    }

 }

application.yml文件

spring:
  cloud:
    stream:
      bindings:
        toUpperCase:
          binder: rabbitTest
          destination: toUpperCase-out-0
        reverse:
            binder: rabbitTest
      binders:
        rabbitTest:
          type: rabbit
          environment:
            spring:
              rabbitmq:
                host: localhost
                port: 5672
                virtual-host: /
                username: ***
                password: ***

共有1个答案

路金鑫
2023-03-14

当我们有多个bean时,需要定义定义属性。从文档

我们使用 --spring.cloud.function.definition 属性来显式声明我们希望绑定到绑定目标的函数 bean。对于只有单个此类 bean 的情况,它不是必需的,但对于所有其他情况,它是

.

 类似资料:
  • 我试图在我的应用程序中集成spring cloud stream kinesis,但我找不到手册中的所有配置选项。我看过这个链接: https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/blob/master/spring-cloud-stream-binder-kinesis-docs/src/main/as

  • Spring Cloud Kafka Streams与Spring Cloud Stream、Spring Cloud Function、Spring AMQP和Spring for Apache Kafka有什么区别?

  • 是否可以使用函数()样式,使用多个独立的函数/绑定来实现反应性SCS应用程序?我发现的所有示例总是只注册一个具有默认绑定的函数bean。我想注册多个,每个都有自己的绑定。 传统上,这可以使用来完成,但现在不推荐使用函数支持。

  • 我用的是Apache Kafka 2.7.0和Spring Cloud Stream Kafka Streams。 在我的Spring Cloud Stream (Kafka Streams)应用程序中,我已经将我的application.yml配置为当输入主题中的消息出现反序列化错误时使用sendToDlq机制: 我启动了我的应用程序,但我看不到这个主题存在。文档指出,如果 DLQ 主题不存在,

  • 问题内容: 有没有一种方法可以自动将Spring bean投射到应用程序上下文XML中定义的类?我想避免将有关Bean的类型信息放在2个地方....在xml配置文件以及代码中作为强制转换。 例如,给定此配置文件 我可以这样调用以避免避免将返回类型直接转换为。我知道我也可以打电话避免强制转换本身,但是我仍然在2个地方输入了类型信息。 看起来Spring可以获取类信息()或从Bean本身获取类型,但是

  • 假设我希望实现与在spring-amqp函数周围使用时基本相同的功能: 在Rabbit绑定器中使用Spring Cloud Stream时,是否必须手动将消息访问到RabbitMQ? 如果是,如何实现?