Correct the classpath of your application so that it contains compatible versions of the classes org

解决办法1
一般这种错误都是重复引入包了,看具体报错的是哪个类,把这个依赖注释掉


解决办法2

  • 第二天的时候,发现了真实的原因,其实重复引入包会报错,这个说法是不严谨的。
  • 最大的问题是在于包版本的问题,我们使用的hibernate-validator默认版本号是6.x,对应java的validation-api的版本应该是2.x,我这里强制指定了1.x,版本没对上。
  • 其实在spring-boot的项目中,我们没必要指定validation-api的版本,直接使用spring-boot的默认版本声明就可以了。
  • 去掉版本号声明以后,我们看到会默认引入的版本是2.x,然后启动,就不会报错了

比如我的完整报错是: Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.validator.internal.xml.config.ValidationBootstrapParameters and javax.validation.BootstrapConfiguration

ValidationBootstrapParameters是hibernate-validator包里的,因为spring-boot-web-starter默认引入了,我这里其实就不需要引入了。

注释掉这个依赖,ok,问题解决


完整报错信息:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.hibernate.validator.internal.xml.config.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:65)

The following method did not exist:

    javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;

The calling method's class, org.hibernate.validator.internal.xml.config.ValidationBootstrapParameters, was loaded from the following location:

    jar:file:/Users/albert/code/repo/org/hibernate/validator/hibernate-validator/6.2.0.Final/hibernate-validator-6.2.0.Final.jar!/org/hibernate/validator/internal/xml/config/ValidationBootstrapParameters.class

The called method's class, javax.validation.BootstrapConfiguration, is available from the following locations:

    jar:file:/Users/albert/code/repo/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar!/javax/validation/BootstrapConfiguration.class
    jar:file:/Users/albert/code/repo/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar!/javax/validation/BootstrapConfiguration.class
    jar:file:/Users/albert/code/repo/javax/javaee-api/8.0/javaee-api-8.0.jar!/javax/validation/BootstrapConfiguration.class

The called method's class hierarchy was loaded from the following locations:

    javax.validation.BootstrapConfiguration: file:/Users/albert/code/repo/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.validator.internal.xml.config.ValidationBootstrapParameters and javax.validation.BootstrapConfiguration


Process finished with exit code 1

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值