The Bean Validation API is on the classpath but no implementation could be found

红太狼 2024-03-23 13:29 144阅读 0赞

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”,如图:
在这里插入图片描述

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

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

解决方案

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

org.hibernate hibernate-validator 6.1.2.Final
如果暂时用不到校验,推荐把校验依赖排除掉,查看下你哪个依赖里面用到了validator-api,就在哪个依赖里面排除掉,比如我的cxf-spring-boot-starter中有用到,那么我就在该依赖中排除掉,pom如图:
在这里插入图片描述

点击运行恢复正常。

发表评论

表情:
评论列表 (有 0 条评论,144人围观)

还没有评论,来说两句吧...

相关阅读