springboot中@Max和@Min注解失效的

方法1:

在类上应该加一个@Validated  ,但是我用了后还是无法正常校准。

方法2:

min和max方法要用对,正确格式:@Max(value=99)

以上两种方法对我都没用,还是不报错也不生效。

方法3:

springboot版本过高,2.3版本后将依赖项hibernate-validator.6.0.13.Final去除,只需要将其加上就ok

 
            org.hibernate.validator
            hibernate-validator
            6.0.13.Final
       

文章取自:

(30条消息) springboot的请求参数约束@Max @Min @NotNull等无效_@min不生效_code-jam的博客-CSDN博客

你可能感兴趣的:(spring,boot,java,spring)