Issue
I have the following config object
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "doginfo")
public class DogConfig {
private Map<BreedEnum, List<String>> attributes;
}
where the BreedEnum
is:
public enum BreedEnum {
PITBULL, CORGI, SHIBA
}
I would like to bind the following properties in application.properties
into DogConfig
:
doginfo.PITBULL.attributes[0]=attrP0
doginfo.PITBULL.attributes[1]=attrP1
doginfo.CORGI.attributes[0]=attrC0
When my app is running, the attributes
config is null. How do I achieve such binding correctly?
Thank you
Solution
The following should work:
doginfo.attributes.PITBULL[0]=attrP0
doginfo.attributes.PITBULL[1]=attrP1
Answered By - João Dias