Spring Boot 2.3 默认弃用validation

2,739 阅读1分钟
项目从spring2.2.6升级到2.3.0以后

validation相关代码找不到(import javax.validation.constraints.NotBlank)

We'll do the following:

remove the spring-boot-starter-validation from spring-boot-starter-web by default change spring-boot-starter-validation to use org.glassfish:jakarta.el instead of the current choice of default implementation update all the web servers starters to use that same el implementation for all

With this change, we don't need to add a new starter and we can consistently use the same el implementation.

解决方案

在pom.xml增加

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
</dependency>

Spring Boot 2.3发行说明