属性文件中kafka生产者的Map配置失败

hgb9j2n6  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(311)

我试图在我的项目中添加一个producer配置,下面使用spring集成和kafka。
因为我找不到地方放它,我想我应该把它添加到我的application.properties下:

spring.cloud.stream.kafka.bindings.output.producer.configuration

但是,我无法使用以下任何格式编译代码:

spring.cloud.stream.kafka.bindings.output.producer.configuration=request.timeout.ms=100000
spring.cloud.stream.kafka.bindings.output.producer.configuration={'request.timeout.ms':'100000'}
spring.cloud.stream.kafka.bindings.output.producer.configuration={"request.timeout.ms":"100000"}
spring.cloud.stream.kafka.bindings.output.producer.configuration=request.timeout.ms:100000

我总是犯这样的错误:

Binding to target org.springframework.cloud.stream.binder.kafka.KafkaExtendedBindingProperties@104392ba failed:

    Property: spring.cloud.stream.kafka.bindings[output].producer.configuration
    Value: request.timeout.ms:100000
    Reason: Failed to convert property value of type 'java.lang.String' to required type 'java.util.Map' for property 'bindings[output].producer.configuration'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Map' for property 'configuration': no matching editors or conversion strategy found

你知道如何将这个配置实现给生产者吗?

pjngdqdw

pjngdqdw1#

应按以下方式使用: spring.cloud.stream.kafka.bindings.output.producer.configuration.request.timeout.ms=100000 配置名称应后跟 spring.cloud.stream.kafka.bindings.<binding name>.producer.configuration 前缀
这样,您可以添加任意数量的配置。

相关问题