欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

springboot 2.3之后消失的hibernate-validator解决方法

程序员文章站 2022-09-25 15:18:07
项目升级到springboot2.3之后,参数校验的注解报错,发现spring-boot-starter-web的依赖项已经去除了依赖点开spring-boot-starter-web源码看了下。&l...

项目升级到springboot2.3之后,参数校验的注解报错,发现spring-boot-starter-web的依赖项已经去除了依赖

点开spring-boot-starter-web源码看了下。

<?xml version="1.0" encoding="utf-8"?>
<project xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/pom/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">
 <!-- this module was also published with a richer model, gradle metadata, -->
 <!-- which should be used instead. do not delete the following line which -->
 <!-- is to indicate to gradle or any gradle module metadata file consumer -->
 <!-- that they should prefer consuming it instead. -->
 <!-- do_not_remove: published-with-gradle-metadata -->
 <modelversion>4.0.0</modelversion>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-starter-web</artifactid>
 <version>2.3.1.release</version>
 <name>spring-boot-starter-web</name>
 <description>starter for building web, including restful, applications using spring mvc. uses tomcat as the default embedded container</description>
 <url>https://spring.io/projects/spring-boot</url>
 <organization>
  <name>pivotal software, inc.</name>
  <url>https://spring.io</url>
 </organization>
 <licenses>
  <license>
   <name>apache license, version 2.0</name>
   <url>https://www.apache.org/licenses/license-2.0</url>
  </license>
 </licenses>
 <developers>
  <developer>
   <name>pivotal</name>
   <email>info@pivotal.io</email>
   <organization>pivotal software, inc.</organization>
   <organizationurl>https://www.spring.io</organizationurl>
  </developer>
 </developers>
 <scm>
  <connection>scm:git:git://github.com/spring-projects/spring-boot.git</connection>
  <developerconnection>scm:git:ssh://git@github.com/spring-projects/spring-boot.git</developerconnection>
  <url>https://github.com/spring-projects/spring-boot</url>
 </scm>
 <issuemanagement>
  <system>github</system>
  <url>https://github.com/spring-projects/spring-boot/issues</url>
 </issuemanagement>
 <dependencymanagement>
  <dependencies>
   <dependency>
    <groupid>org.springframework.boot</groupid>
    <artifactid>spring-boot-dependencies</artifactid>
    <version>2.3.1.release</version>
    <type>pom</type>
    <scope>import</scope>
   </dependency>
  </dependencies>
 </dependencymanagement>
 <dependencies>
  <dependency>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-starter</artifactid>
   <version>2.3.1.release</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-starter-json</artifactid>
   <version>2.3.1.release</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-starter-tomcat</artifactid>
   <version>2.3.1.release</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupid>org.springframework</groupid>
   <artifactid>spring-web</artifactid>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupid>org.springframework</groupid>
   <artifactid>spring-webmvc</artifactid>
   <scope>compile</scope>
  </dependency>
 </dependencies>
</project>

没有发现 hibernate-validator

原版本如下:

<dependency>
   <groupid>org.hibernate.validator</groupid>
   <artifactid>hibernate-validator</artifactid>
   <version>6.0.17.final</version>
   <scope>compile</scope>
 </dependency>

刚看了一下官方文档。需要手动引入

<dependency>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-starter-validation</artifactid>
 </dependency>

到此这篇关于springboot 2.3之后消失的hibernate-validator解决方法的文章就介绍到这了,更多相关springboot2.3 hibernate-validator内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!