1. The error is as follows:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint ' javax.validation.constraints.NotBlank ' validating type ' java.lang.String ' . Check configuration for ' orderTime '
at org.hibernate.validator. internal .engine .constraintvalidation.ConstraintTree.throwExceptionForNullValidator(ConstraintTree.java: 227 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.getConstraintValidatorNoUnwrapping (ConstraintTree.java:308 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.getConstraintValidatorInstanceForAutomaticUnwrapping (ConstraintTree.java:242 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.getInitializedConstraintValidator (ConstraintTree.java:163 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.validateConstraints (ConstraintTree.java: 116 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.constraintvalidation.ConstraintTree.validateConstraints (ConstraintTree.java:87 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java: 73 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validateMetaConstraint (ValidatorImpl.java:616 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraint (ValidatorImpl.java:581 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement (ValidatorImpl.java:527 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraintsForDefaultGroup (ValidatorImpl.java:495 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validateConstraintsForCurrentGroup (ValidatorImpl.java:460 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validateInContext (ValidatorImpl.java:410 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]
at org.hibernate.validator.internal .engine.ValidatorImpl.validate (ValidatorImpl.java:207 ) ~ [ hibernate - validator - 5.4.1.Final.jar : 5.4.1.Final ]at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate
(SpringValidatorAdapter.java:109 ) ~ [spring- context - 5.3.22.jar : 5.3.22 ]
at org.springframework.boot.autoconfigure.validation.ValidatorAdapter.validate(ValidatorAdapter.java:66 ) ~ [ spring - boot - autoconfigure - 2.7.2.jar : 2.7.2 ]
at org.springframework.validation.DataBinder.validate(DataBinder.java:933 ) ~ [spring - context - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.validateIfApplicable(AbstractMessageConverterMethodArgumentResolver.java:250 ) ~ [spring - webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:139 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122 ) ~ [spring - web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues
(InvocableHandlerMethod.java:179 ) ~ [spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest
(InvocableHandlerMethod.java:146 ) ~ [spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle
(ServletInvocableHandlerMethod.java:117 ) ~ [spring- webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87 ) ~ [spring - webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1070 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963 ) ~ [ spring- webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006 ) [ spring - webmvc - 5.3.22.jar : 5.3.22 ]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909 ) [ spring - webmvc - 5.3.22.jar : 5.3.22 ]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681 ) [tomcat-embed- core - 9.0.65.jar : 4.0.FR ]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883 ) [ spring - webmvc - 5.3.22.jar : 5.3.22 ]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764 ) [tomcat-embed- core - 9.0.65.jar : 4.0.FR ]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53 ) [ tomcat-embed - websocket - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100 ) [ spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter
(OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]at
org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93 ) [ spring- web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter
(OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96 ) [ spring - boot- actuator - 2.7.2.jar : 2.7.2 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter
(OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201 ) [spring - web - 5.3.22.jar : 5.3.22 ]at org.springframework.web.filter.OncePerRequestFilter.doFilter
(OncePerRequestFilter.java:117 ) [ spring- web - 5.3.22.jar : 5.3.22 ]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162 ) [tomcat- embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:92 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:360 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]at org.apache.coyote.http11.Http11Processor.service
(Http11Processor.java:399 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.coyote.AbstractProtocol
$ConnectionHandler.process(AbstractProtocol.java:890 ) [tomcat-embed - core - 9.0.65.jar : 9.0.65 ]at org.apache.tomcat.util.net.NioEndpoint$ SocketProcessor.doRun
(NioEndpoint.java:1789 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191 ) [ tomcat-embed - core - 9.0.65.jar : 9.0.65 ]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659 ) [ tomcat -embed- core - 9.0.65.jar : 9.0.65 ]at org.apache.tomcat.util.threads.TaskThread
$WrappingRunnable.run(TaskThread.java:61 ) [ tomcat-embed- core - 9.0.65.jar : 9.0.65 ]
at java.lang.Thread.run(Thread.java: 748 ) [na: 1.8.0_301 ]
The entity class is as follows:
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Data
public class OutstoreCodeVO {
@NotBlank(message = "The outbound order number cannot be empty " )
private String orderNo;
@Valid
@NotEmpty(message = "The traceback code array cannot be empty " )
private List<String> codes;
}
2. Reason analysis: The annotations cannot be recognized due to different versions:
(1), when the version is org.hibernate.validator:hibernate-validator:6.0.13.Final
The imported dependencies are:
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
(2), when the version is org.hibernate.validator:hibernate-validator:6.2.3.Final
The imported dependencies must be:
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
3. Solution: Since the version is version 6.2.3, the package introduced by the @NotBlank and @NotEmpty annotations is changed to:
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;