温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

项目升级到springboot2.3之后hibernate-validator消失了如何解决

发布时间:2020-08-13 11:34:29 来源:亿速云 阅读:431 作者:小新 栏目:开发技术

小编给大家分享一下项目升级到springboot2.3之后hibernate-validator消失了如何解决,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

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

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

<&#63;xml version="1.0" encoding="UTF-8"&#63;>
<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>

看完了这篇文章,相信你对项目升级到springboot2.3之后hibernate-validator消失了如何解决有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI