Spring Cloud Stream功能无法识别

问题描述 投票:0回答:1

我有一个 Spring Boot Kafka 流应用程序。 升级到SB3后,spring.cloud.function.definition不再被识别。

我启用了调试日志并提供了帮助。 我在日志中看到这些消息:

Multiple functional beans were found [myEvents, sendToDlqAndContinue], thus can't determine default function definition. Please use 'spring.cloud.function.definition' property to explicitly define it. 

这是我的

application.yml
:

spring:
  application:
    name: @project.artifactId@
  cloud:
    config:
      name: my-app
    stream:
      default:
        producer:
          useNativeEncoding: true
      function:
        definition:myEvents
        ineligible-definitions: sendToDlqAndContinue

这些是我的依赖项:


<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>3.1.5</version>
    </parent>
<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-kafka-streams</artifactId>
        </dependency>
</dependencies>

我尝试调试报告错误的云流Kafka类,BeanFactoryAwareFuntionRegistry.java

发现

this.applicationContext.getEnvironment().getProperty(FunctionProperties.FUNCTION_DEFINITION, "");
是“”

它确实包含

ineligible-definitions
我在 yml 中有,但不是
definition

任何线索都将受到高度赞赏。也许SpringBoot 3中有一些与云流相关的变化?缺少依赖吗?

更新

我尝试在添加依赖项后运行应用程序:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-properties-migrator</artifactId>
    <scope>runtime</scope>
</dependency>

应用程序现在使用消息,但依赖项不会记录不支持或迁移的属性。我如何知道哪个属性被删除/迁移?

我没有找到有关新版本更改的官方文档。

migration spring-kafka spring-cloud-stream-binder-kafka spring-cloud-function java-20
1个回答
0
投票

我已将

spring.cloud.stream.function
更改为
spring.cloud.function
,它对我有用。

未来

application.yml

spring:
  application:
    name: @project.artifactId@
  cloud:
    config:
      name: my-app
    function:
      definition:myEvents
      ineligible-definitions: sendToDlqAndContinue
    stream:
      default:
        producer:
          useNativeEncoding: true

但是,官方文档说这两种配置都有效。

要指定将哪个功能bean绑定到绑定公开的外部目标,您必须提供 spring.cloud.stream.function.definition 或 spring-cloud-function 本机 spring.cloud.function.definition 属性。

而且,你应该检查这个url,它对我有用。

我将

class
更改为
function

我希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.