我已将 Spring Boot 项目从 2.2.5 迁移到 2.3.0,之后,验证停止工作(根本不调用它们)。
我在变更日志文档中读到(https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-M1-Release-Notes https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-M1-Release-Notes), that spring-boot-starter-validation
现在需要手动添加为依赖项。
所以,我将其添加到我的 pom.xml 中:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
我的 pom 父母是:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath></relativePath>
</parent>
我的控制器看起来像这样:
@PostMapping( value = "/signup", consumes = MediaType.APPLICATION_JSON_VALUE )
@ResponseStatus( value = HttpStatus.OK )
public void signUp( @Valid @RequestBody ClientDto clientDto )
{
onboardingService.signUp( clientDto );
}
EDIT:
我找到了这个问题,请在下面查看我的答案!
谢谢大家的帮助!
验证启动器不再包含在网络启动器中。
spring-boot-starter-validation 不再是 spring-boot-starter-web 和 spring-boot-starter-webflux 的传递依赖项。
添加此依赖项以进行验证工作。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)