Search code examples
spring-bootyaml

How to define multiple packages as trusted package in yaml


I have a Spring boot application where I am consuming data from Kafka topics. For the Objects which I consume, I need to provide their package names as trusted packages.

eg.

spring:
   kafka:
     consumer:
        bootstrap-servers: localhost:9092
        group-id: group_id
        auto-offset-reset: earliest
        key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
        value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
        properties:
          spring:
            json:
              trusted:
                packages: com.sample.cassandra

Now I have multiple packages which I need to define as trusted package.

For example I have com.sample.demo, but when I try something like this:

spring:
                json:
                  trusted:
                    packages: com.sample.cassandra, com.sample.demo

It doesn't work.

What would be the correct syntax to define multiple packages in the yaml file?


Solution

  • The YAML syntax for sequences is

    packages: [com.sample.cassandra, com.sample.demo]
    

    You can alternatively use the block syntax:

    packages:
      - com.sample.cassandra
      - com.sample.demo