pjverity opened SPR-17462 and commented

Using spring-boot 2.1.0.RELEASE, I use the starter:

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>

This places javax.validation:validation-api:2.0.1.Final on the classpath. That version of the validation API has an interface method ValidatorFactory.``ClockProvider getClockProvider() which isn't implemented by LocalValidatorFactoryBean.

The code is here:

https://github.com/spring-projects/spring-framework/blob/a0880f7ea97a0329aaf1b7dbe0877eca10f060f8/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java#L87


Affects: 5.1.2

Reference URL: https://github.com/spring-projects/spring-framework/blob/a0880f7ea97a0329aaf1b7dbe0877eca10f060f8/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java#L87

Comment From: spring-projects-issues

pjverity commented

Ah. Just read the JavaDoc - perhaps this is intentional.

If you'd like to call BV 2.0's getClockProvider() method, obtain the native ValidatorFactory through unwrap(ValidatorFactory.class)

Comment From: spring-projects-issues

Juergen Hoeller commented

Indeed, this is intentional since we need to retain Bean Validation 1.1 compatibility at runtime for the time being. LocalValidatorFactoryBean is only really a bootstrap delegate and not internally injected into constraint implementations (which is where getClockProvider() is meant to be used), so there shouldn't be any practical implications.

Comment From: VikkeyJiang

usually we cannt compile a class without implemets all interface method , i'm curious about how spring makes it work~