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

查看:477
本文介绍了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).

我阅读了changelog文档(

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父母是:

<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 );
}

我能够找到该问题,请检查下面的答案!

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

感谢大家的帮助!

推荐答案

根据spring boot 2.3.1版本 不再包含带有Spring Starter的spring-boot-starter-validation

According to spring boot 2.3.1 release there is no longer contains spring-boot-starter-validation with spring starter

如何在

专家

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

成绩

dependencies {
  ...
  implementation 'org.springframework.boot:spring-boot-starter-validation'
}

裁判发布说明

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web -启动器

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

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