Spring Boot - 从 2.2.5 升级到 2.3.0 后验证停止工作 [英] Spring Boot - Validations stopped working after upgrade from 2.2.5 to 2.3.0

查看:31
本文介绍了Spring Boot - 从 2.2.5 升级到 2.3.0 后验证停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Spring Boot 项目从 2.2.5 迁移到 2.3.0,之后,验证停止工作(根本没有调用它们).

I've migrated a Spring Boot project from 2.2.5 to 2.3.0 and after that, Validations stopped to work (they aren't invoked at all).

我阅读了变更日志文档(https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-M1-Release-Notes),即 spring-boot-starter-validation 现在需要手动添加为依赖项.

I read in changelog documentation (https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-M1-Release-Notes), that spring-boot-starter-validation now needs to be added manually as a dependency.

所以,我将它添加到我的 pom.xml 中:

So, I added it to my pom.xml:

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

我的 pom 父母是:

My pom parent is:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.0.RELEASE</version>
    <relativePath></relativePath>
</parent>

我的控制器看起来像这样:

My Controller looks like this:

@PostMapping( value = "/signup", consumes = MediaType.APPLICATION_JSON_VALUE )
@ResponseStatus( value = HttpStatus.OK )
public void signUp( @Valid @RequestBody ClientDto clientDto )
{
    onboardingService.signUp( clientDto );
}

我找到了问题,请查看下面的答案!

I WAS ABLE TO FOUND THE ISSUE, CHECK MY ANSWER BELOW!

感谢大家的帮助!

推荐答案

验证启动器不再包含在 Web 启动器中.

Validation starter not included in web starters anymore.

spring-boot-starter-validation 不再是 spring-boot-starter-web 和 spring-boot-starter-webflux 的传递依赖.

The spring-boot-starter-validation is not a transitive dependency of spring-boot-starter-web and spring-boot-starter-webflux anymore.

为验证工作添加此依赖项.

Add this dependency for validations work.

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

这篇关于Spring Boot - 从 2.2.5 升级到 2.3.0 后验证停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆