维护别人的项目的时候遇到一个问题,@Validated怎么都不生效
解决:
老项目使用的
<dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.1.Final</version> </dependency>
修改成
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>
原因是依赖没有被解析
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: