Reputation: 817
is there a way to valid the properties bean?
@Data
public class ProjectProperties {
@NotBlank
@NotEmpty
private String description;
}
create the bean with:
@Bean
@ConfigurationProperties(prefix = "project")
@Valid
public ProjectProperties getProjectProperties() {
return new ProjectProperties();
}
and my application.properties:
project.description =
Is there different way to make the validation work?
Upvotes: 0
Views: 79
Reputation: 929
@Data
@Validated
public class ProjectProperties {
@NotBlank
@NotEmpty
private String description;
}
Upvotes: 1