I'm making a Spring Boot Kafka Streams application (Not Spring Cloud)
When set up configuration, as I know, there are two way to set configuration.
The first way is making a config bean like below
@Configuration
@EnableKafka
@EnableKafkaStreams
public class KafkaConfig {
@Value(value = "${spring.kafka.bootstrap-servers}")
private String bootstrapAddress;
@Bean(name = KafkaStreamsDefaultConfiguration.DEFAULT_STREAMS_CONFIG_BEAN_NAME)
KafkaStreamsConfiguration kStreamsConfig() {
Map<String, Object> props = new HashMap<>();
props.put(APPLICATION_ID_CONFIG, "streams-app");
props.put(BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
props.put(DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
return new KafkaStreamsConfiguration(props);
}
}
Second way is set config at application.properties
spring.kafka.streams.application-id=streams-app
spring.kafka.streams.bootstrap-servers=localhost:9092
In the first way, StreamsConfig has DEFAULT_KEY/VALUE_SERDE_CLASS_CONFIG properties to set default.key.serde and default.value.serde.
But in application.properties, I don't know how can set that properties. also autocompletion doesn't exist.
In short, Is there a way to set default.key.serde and default.value.serde in application.properties?
I tried
spring.kafka.streams.default-key-serde
spring.kafka.streams.default.key.serde
spring.kafka.streams.default-key-serde-class
spring.kafka.streams.properties.default-key-serde
etc. But nothing works
Use square brackets
spring.kafka.streams.properties[default.key.serde]="..."