loading...

re: Spring @ConfigurationProperties annotation explained VIEW POST

FULL DISCUSSION
 

Thanks for the post.

What I like most about the feature is the possibility to avoid setters() using @ConstructorBinding, making the properties from a YAML private final and therefore immutable. And this goes hand in hand with Lombok's @AllArgsConstructor and @Getter.

For example:

@Getter
@Validated
@AllArgsConstructor
@ConstructorBinding
@ConfigurationProperties("foo")
public class FooBarProperties {

    @NotBlank
    private final String bar;

}
Code of Conduct Report abuse