【发布时间】:2020-09-09 13:59:50
【问题描述】:
我已将 Spring Boot 项目从 2.2.5 迁移到 2.3.0,之后,验证停止工作(根本没有调用它们)。
我在更改日志文档 (https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-M1-Release-Notes) 中读到,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 );
}
编辑:
我能够找到问题,请在下面查看我的答案!
感谢大家的帮助!
【问题讨论】:
-
请问你能显示完整的 pom.xml 吗
-
@CodeScale 我的 pom 非常复杂(几个 maven 模块有很多依赖项和插件)。我添加了
部分。你还有什么感兴趣的吗?感谢您的帮助。 -
你可以参考这里docs.spring.io/spring/docs/current/javadoc-api/org/…这是springs实现,尝试将@Validated添加到你的控制器
-
@silentsudo 在从 Spring Boot 2.2.5 迁移到 2.3.0 之前它正在工作
-
@martins.tuga 之前和之后的类路径比较了吗?
标签: java spring spring-boot validation