Summary:
ValidationAutoConfiguration.methodValidationPostProcessor
should have @ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
Demo code: https://github.com/cmercer/spring-boot-validation-issue The above code has a fix enabled by default, readme contains information about reenabling the break.
Details: One of my project has a rather complicated deployment which spiders out application contexts somewhat like the following.
- parent
- web1 parent
- web1
- web2 parent
- web2
- web3 parent
- web3
One of the things I found is method validation would not work correctly in our web apps.
I think this is because BeanPostProcessors are only applied when they are in the current application context and not from the parent context (which makes senses). But ValidationAutoConfiguration.methodValidationPostProcessor finds that the it already exists in the parent context and does not create it in the child context.
This not only effected controllers, but also any Bean that might have any validation on its methods, such as NotNull, NotBlank etc.
The demo app above is against 2.5.4, but this issue exists at least back to 2.3.9.