我正在尝试使用下面的Spring Integration和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
有什么想法要对生产者实施这种配置吗?
答案 0 :(得分:1)
您应通过以下方式使用:
spring.cloud.stream.kafka.bindings.output.producer.configuration.request.timeout.ms=100000
配置名称后应紧跟
spring.cloud.stream.kafka.bindings.<binding name>.producer.configuration
前缀
通过这种方式,您可以添加任意数量的配置。