Search code examples
springspring-bootspring-kafkaspring-cloud-streamspring-cloud-stream-binder-kafka

PropertySource in spring boot doesn't seem to work


I cannot load StringDeserializer and StringSerializer with PropertySource, but all other spring.kafka related things get loaded.

Is it a bug in spring PropertySource?

My common application look like this:

@Configuration
@PropertySource("classpath:/config/kafka.properties")
public class CommonKafkaAutoConfiguration {
}

Below configuration doesn't get loaded when filename kafka.properties but okay when application.properties

spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer

Funny fact is following get loaded in both cases:

spring.kafka.consumer.max-poll-records=20

Update I can see that its get overriden by kafkaBinderDefaultProperties


Solution

  • The error occur because of KafkaBinderEnvironmentPostProcessor

    I solved it by creating my own EnvironmentPostProcessor