gpt4 book ai didi

spring-boot - Cloud Kafka with spring boot 给我错误

转载 作者:行者123 更新时间:2023-12-02 00:12:18 25 4
gpt4 key购买 nike

嘿,我遵循了在 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.cloud.function.definition”属性。

最佳答案

Spring Cloud Function 在应用程序中执行以下操作:

  1. 搜索任何 Spring 管理的 bean实现 OR 符合功能接口(interface)的约定 Supplier<T> , Consumer<T>Function<T, R> .
  2. 标记这些 beans作为潜力beans绑定(bind)到事件端点(绑定(bind))。
  3. 如果只有一个Spring管理bean在步骤 1 中解决,那么该 bean 将是唯一的 bean绑定(bind)为应用程序公开的函数(绑定(bind)到外部事件端点)——有效地假设应用程序是一个Serverless Function。 .
  4. 如果有多个Spring托管bean在步骤 1 中解决,然后 Spring Cloud Function 将查看属性 spring.cloud.function.definition解决哪些beans应该绑定(bind)到端点。
  5. 如果未分配此属性,则 Spring Cloud Function 将抛出 IllegalArgumentException。 (你得到的那个)提示它无法解决你想要暴露的 beans(在所有潜在的 功能性 bean 中)。
  6. 分配给属性的值 spring.cloud.function.definition将被读作 semi-colon separated list of functional bean names

因此,要解决您的问题,您需要:

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

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

spring.cloud.function.definition=persistentEntities;resourceMappings

希望这对您有所帮助。

关于spring-boot - Cloud Kafka with spring boot 给我错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58574446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com