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

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

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

解决方案

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

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

点击运行恢复正常。

猜你喜欢

转载自blog.csdn.net/weixin_44659084/article/details/130200967