加了@NotBlank和@Valid后没有生效,找了很久错误,大部分都是要导包,但是我把所有可能的jar包都导了,还是没用,最后发现是springboot版本的问题
直接在pom文件中加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
原文链接:https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes