I\'m wondering, if there is a generic way to fill a map with properties you just know the prefix.
Assuming there are a bunch of properties like
names
I was going nuts trying to understand why @Andy's answer wasn't working for me (as in, the Map
was remaining empty) just to realize that I had Lombok's @Builder
annotation getting in the way, which added a non-empty constructor. I'm adding this answer to emphasize that in order for @ConfigurationProperties
to work on Map
, the value type must have a No-Arguments constructor. This is also mentioned in Spring's documentation:
Such arrangement relies on a default empty constructor and getters and setters are usually mandatory ...
I hope this will save someone else some time.