Zuordnungsliste in Yaml zu Liste der Objekte in Spring Boot

In meiner Spring Boot-App habe ich die Konfigurationsdatei application.yaml mit folgendem Inhalt. Ich möchte, dass es als Konfigurationsobjekt mit einer Liste von Kanalkonfigurationen injiziert wird:

available-payment-channels-list:
  xyz: "123"
  channelConfigurations:
    -
      name: "Company X"
      companyBankAccount: "1000200030004000"
    -
      name: "Company Y"
      companyBankAccount: "1000200030004000"

Und @Configuration-Objekt Ich möchte mit einer Liste von PaymentConfiguration-Objekten gefüllt werden:

    @ConfigurationProperties(prefix = "available-payment-channels-list")
    @Configuration
    @RefreshScope
    public class AvailableChannelsConfiguration {

        private String xyz;

        private List<ChannelConfiguration> channelConfigurations;

        public AvailableChannelsConfiguration(String xyz, List<ChannelConfiguration> channelConfigurations) {
            this.xyz = xyz;
            this.channelConfigurations = channelConfigurations;
        }

        public AvailableChannelsConfiguration() {

        }

        // getters, setters


        @ConfigurationProperties(prefix = "available-payment-channels-list.channelConfigurations")
        @Configuration
        public static class ChannelConfiguration {
            private String name;
            private String companyBankAccount;

            public ChannelConfiguration(String name, String companyBankAccount) {
                this.name = name;
                this.companyBankAccount = companyBankAccount;
            }

            public ChannelConfiguration() {
            }

            // getters, setters
        }

    }

Ich injiziere dies als normale Bean mit dem @Autowired-Konstruktor. Der Wert von xyz ist korrekt angegeben, aber wenn Spring versucht, yaml in eine Liste von Objekten zu zerlegen, die ich erhalte, wird

   nested exception is java.lang.IllegalStateException: 
    Cannot convert value of type [java.lang.String] to required type    
    [io.example.AvailableChannelsConfiguration$ChannelConfiguration] 
    for property 'channelConfigurations[0]': no matching editors or 
    conversion strategy found]

Irgendwelche Hinweise, was hier falsch ist?

Antworten auf die Frage(10)

Ihre Antwort auf die Frage