Simplify property validation sample and document need for static bean method
Closes gh-6627
This commit is contained in:
@@ -1070,9 +1070,13 @@ as `@Valid` to trigger its validation. For example, building upon the above
|
||||
----
|
||||
|
||||
You can also add a custom Spring `Validator` by creating a bean definition called
|
||||
`configurationPropertiesValidator`. There is a
|
||||
{github-code}/spring-boot-samples/spring-boot-sample-property-validation[Validation sample]
|
||||
so you can see how to set things up.
|
||||
`configurationPropertiesValidator`. The `@Bean` method should be declared `static`. The
|
||||
configuration properties validator is created very early in the application's lifecycle
|
||||
and declaring the `@Bean` method as static allows the bean to be created without having to
|
||||
instantiate the `@Configuration` class. This avoids any problems that may be caused by
|
||||
early instantiation. There is a
|
||||
{github-code}/spring-boot-samples/spring-boot-sample-property-validation[property
|
||||
validation sample] so you can see how to set things up.
|
||||
|
||||
TIP: The `spring-boot-actuator` module includes an endpoint that exposes all
|
||||
`@ConfigurationProperties` beans. Simply point your web browser to `/configprops`
|
||||
|
||||
Reference in New Issue
Block a user