I have a Spring boot application where I am reading a JSON property file with @ConfigurationProperties annotation:
@Component
@ConfigurationProperties(prefix = "my-config")
@RefreshScope
public class MyConfig {
private List<Service> services;
private List<Consumer> consumers;
...
Here I would like to add validation while Spring Boot load the property file if something is null or minimum value in the array/list is 1 etc..
I know Spring Boot is using Jackson in the background to perform marshall/unmarshalling between JSON and POJO. I cannot find anything in Jackson which enforce this validation.
Different forums suggest the standard JSR-303 validation however it only works with Rest APIs and not while loading the properties.