Spring boot 带spring boot的Cloud Kafka给了我错误

Spring boot 带spring boot的Cloud Kafka给了我错误,spring-boot,spring-cloud,spring-kafka,spring-cloud-stream,spring-cloud-function,Spring Boot,Spring Cloud,Spring Kafka,Spring Cloud Stream,Spring Cloud Function,嘿,我遵循了在spring boot中设置kafka的分步指南 但现在我无法启动应用程序。任何建议:) 日志中的错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'functionInitializer' defined in class path resource [org/springframework/cloud/stream/function/Functio

嘿,我遵循了在spring boot中设置kafka的分步指南

但现在我无法启动应用程序。任何建议:)

日志中的错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'functionInitializer' defined in class path resource [org/springframework/cloud/stream/function/FunctionConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Found more then one function in BeanFactory: [persistentEntities, resourceMappings]. Consider providing 'spring.cloud.function.definition' property.
什么是spring.cloud.function.definition?如何设置它?
原因:java.lang.IllegalArgumentException:在BeanFactory中找到多个函数:[persistentEntities,resourceMappings]。考虑提供“Spring,云,函数,定义”属性。

< P> Spring云函数在应用程序中执行以下操作:

  • 搜索任何Spring管理的
    bean
    ,该bean实现或符合功能接口
    供应商
    消费者
    功能
    的合同
  • 将这些
    bean
    标记为可能绑定到事件端点(绑定)的
    bean
  • 如果在步骤1中只有一个Spring管理的
    bean
    被解析,那么该bean将是应用程序作为函数公开(绑定到外部事件端点)绑定的唯一
    bean
    ——有效地假设应用程序是一个
  • 如果在步骤1中解析了多个Spring托管
    bean
    ,则Spring Cloud函数将查看属性
    Spring.Cloud.Function.definition
    ,以解析哪些
    bean
    应绑定到端点
  • 如果未分配此属性,则Spring Cloud函数将抛出一个
    IllegalArgumentException
    (您得到的那个),抱怨它无法解析您想要公开的bean(在它找到的所有潜在函数
    bean
    中)
  • 分配给属性
    spring.cloud.function.definition
    的值将作为
  • 因此,要解决您的问题,您需要:

    • 只需在Spring上下文bean
      persistentEntities
      或bean
      resourceMappings
      中注册即可;但不是两者都有

    • 将以下条目添加到Spring上下文的属性中:


    希望这有帮助。

    您需要显示代码和配置。属性告诉框架要绑定哪个函数。
    spring.cloud.function.definition=persistentEntities;resourceMappings