From cedac27c804f72f9dd5738843ec33e7aa609a96e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 16 Dec 2016 12:13:26 +0000 Subject: [PATCH] Require Bean Validation 1.1 to enable validation auto-configuration Previously, ValidationAutoConfiguration would configure a MethodValidationPostProcessor if any Bean Validation 1.0 or later implementation was available, however the underlying infrastructure requires Bean Validation 1.1 with any implementation or Bean Validation 1.0 with Hibernate Validator 4.3. This caused a problem on TomEE which uses Apache BVal, and Bean Validation 1.0 implementation. Spring Framework would identify that Bean Validaton 1.0 was being used and then try to load Hibernate Validator classes that are not present. This commit fixes the problem by requiring Bean Validation 1.1 before auto-configuring a MethodValidationPostProcessor. Closes gh-7665 --- .../autoconfigure/validation/ValidationAutoConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java index 37e9713c80..0aefeda100 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java @@ -17,7 +17,7 @@ package org.springframework.boot.autoconfigure.validation; import javax.validation.Validation; -import javax.validation.Validator; +import javax.validation.executable.ExecutableValidator; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -41,7 +41,7 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess * @author Stephane Nicoll * @since 1.5.0 */ -@ConditionalOnClass({ Validator.class }) +@ConditionalOnClass(ExecutableValidator.class) public class ValidationAutoConfiguration { @Bean