新版的出现如下提示:
Spring Boot 2.3 Release Notes · spring-projects/spring-boot Wiki · GitHub
Validation Starter no longer included in web starters
As of #19550, Web and WebFlux starters do not depend on the validation starter by default anymore. If your application is using validation features, for example you find that
javax.validation.*
imports are not being resolved, you’ll need to add the starter yourself.For Maven builds, you can do that with the following:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
加了这个依赖,之后重新import,就可以正常校验参数了。