Skip to content

yichunzhao/aircraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ConfigurationProperties

Binding Properties to POJO

Spring annotation @Validated triggers bean validation. It informs the Spring to put the bean in the validator.

Using @ConfigurationProperties may binding a group of properties in an object, meanwhile making them validated.

image

@Validated implements a proxy pattern that wraps the proxied data model. However, it introduces proxy behaviours. It may be not a good practice to @Validated data model.

@Validated can be applied on the class level and combined with contrain annotations(@min,@max etc) on the method arguments(primitieve type), or @valid with a complex data type(a nested data model).

Spring-boot-configuration-processor

Adding the dependency above, rebuilding the project. It generates a json file that list beans annotated with @ConfigurationProperties. This json file is used by the IDE to provide auto-completion and documentation for the properties when editing application.properties and application.yaml files.

image