私は以下のような構成を持っています
spring:
source:
prop1: ['abc', 'def']
prop2: some-value
destination:
prop1: some-other-value
以下のクラスで上記の構成を読み取ろうとしています
@Configuration
@ConfigurationProperties(prefix = "spring")
@Getter
@Setter
public class ClientConfiguration {
private Source source;
private Destination destination;
}
@Getter
@Setter
@AllArgsConstructor
@Configuration
@ConfigurationProperties(prefix = "source")
public class Source {
private List<String> prop1;
private String prop2;
}
@AllArgsConstructor
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "destination")
public class Destination {
private String prop1;
}
ただし、このセットアップでエラーが発生します。
Could not bind properties to ClientConfiguration (prefix=spring, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'source' of bean class [ClientConfiguration$$EnhancerBySpringCGLIB$$f1eacf3e]: Could not instantiate property type [Source] to auto-grow nested property path; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [Source]: Is it an abstract class?; nested exception is java.lang.InstantiationException: Source
ネストされたオブジェクトを使用して、ネストされた構成を解析する方法を教えてください。