javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.Integer

[java]  view plain copy print ?
  1. Apr 82014 2:13:57 PM org.apache.catalina.core.StandardWrapperValve invoke  
  2. SEVERE: Servlet.service() for servlet springmvc threw exception  
  3. javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.Integer  
  4.     at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:383)  
  5.     at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:364)  
  6.     at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:313)  
  7.     at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:144)  
  8.     at org.hibernate.validator.engine.ConstraintTree.validateComposingConstraints(ConstraintTree.java:233)  
  9.     at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:128)  
  10.     at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:117)  
  11.     at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:84)  
  12.     at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:452)  


使用hibernate validator出现上面的错误, 需要 注意

@NotNull 和 @NotEmpty  和@NotBlank 区别

  • @NotEmpty 用在集合类上面
  • @NotBlank 用在String上面
  • @NotNull    用在基本类型上


如果在基本类型上面用NotEmpty或者NotBlank 会出现上面的错

你可能感兴趣的:(javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.Integer)