Search code examples
spring-bootyamlapache-kafka-streams

Found duplicate key in application.yml


I have been working on a kafka stream project I am new to yaml files I have been using application.properties . Basically I want to use kafka properties as well as spring fox properties here is my

application.yml

spring:
  cloud:
    function:
      definition: consumer;producer
    stream:
      kafka:
        bindings:
          producer-out-0:
            producer:
              configuration:
                value.serializer: <packagename>

          consumer-in-0:
            consumer:
              configuration:
                value.deserializer: <packagename>
        binder:
          brokers: localhost:9092   
      bindings:
        producer-out-0:
          destination: <topic name>
          producer:
            useNativeEncoding: true # Enables using the custom serializer
        consumer-in-0:
          destination: <topic name>
          consumer:
            use-native-decoding: true # Enables using the custom deserializer 
spring:
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER   

It shows

in 'reader', line 1, column 1:
    spring:
    ^
found duplicate key spring
 in 'reader', line 31, column 1:
    spring:
    ^

I tried add mvc: in between and other things nothing seem to work I dont know how to get spring key as parent to mvc: pathmatch: without ruining above configuration


Solution

  • spring is a duplicate! Your YAML should look like this:

    spring:
      cloud:
        function:
          definition: consumer;producer
        stream:
          kafka:
            bindings:
              producer-out-0:
                producer:
                  configuration:
                    value.serializer: <packagename>
    
              consumer-in-0:
                consumer:
                  configuration:
                    value.deserializer: <packagename>
            binder:
              brokers: localhost:9092   
          bindings:
            producer-out-0:
              destination: <topic name>
              producer:
                useNativeEncoding: true # Enables using the custom serializer
            consumer-in-0:
              destination: <topic name>
              consumer:
                use-native-decoding: true # Enables using the custom deserializer 
      mvc:
        pathmatch:
          matching-strategy: ANT_PATH_MATCHER