springboot项目报错-The Bean Validation API is on the classpath but no implementation could be found

springboot项目报错-The Bean Validation API is on the classpath but no implementation could be found


目录

文章目录




内容

新建简单的cxf整合springboot项目,但是控制台报错”The Bean Validation API is on the classpath but no implementation could be found”,如图:[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-q7WSbL6b-1601046287130)(./images/2020-09-23_not-fount-bean-validation.png)]

但是我项目中就一个简单的Bean User类,并没有用到Validation,为什么会报错呢?

网上查看了下,原因是版本不兼容问题。

解决方案

  1. 如果需要用到校验,那么推荐在依赖中添加一种校验实现,如hibernate-validator,版本自己选中,pom.xml依赖如下,

    org.hibernate hibernate-validator 6.1.2.Final
  2. 如果暂时用不到校验,推荐把校验依赖排除掉,查看下你哪个依赖里面用到了validator-api,就在哪个依赖里面排除掉,比如我的cxf-spring-boot-starter中有用到,那么我就在该依赖中排除掉,pom如图:[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jkm2Roor-1601046287133)(./images/2020-09-23_resolution.png)]

点击运行恢复正常。

后记

本项目为参考某马视频开发,相关视频及配套资料可自行度娘或者联系本人。上面为自己编写的开发文档,持续更新。欢迎交流,本人QQ:806797785

前端项目源代码地址:https://gitee.com/gaogzhen/ly-bms    // 前端后台管理系统
后端JAVA源代码地址:https://gitee.com/gaogzhen/ly-backend        // 后端项目

猜你喜欢

转载自blog.csdn.net/gaogzhen/article/details/108805746