If you’re working with some Spring projects, you probably tried to make a @ConfigurationProperties annotated class already and it’s giving nulls, your configuration also looks something like this:
@ConfigurationProperties(prefix = "some.prefix")
public class ConfigurationProperties {
private String[] interestingValue;
}
Solution: You need getters and setter methods :), luckily lombok has an easy way of doing this: @Data
One line change:
@Data
@ConfigurationProperties(prefix = "some.prefix")
public class ConfigurationProperties {
private String[] interestingValue;
}
Also make sure to add @EnableConfigurationProperties(ConfigurationProperties.class) to your application class.
Leave a Reply