解決:did not exist: javax.persistence.Table.indexes()[Ljavax/persistence/Index

1、問題

剛剛在用springboot配置多數據源時,報錯如下:

Description:

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

  •     org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1236)

The following method did not exist: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

The method's class, javax.persistence.Table, is available from the following locations:

  •     jar:file:/C:/practice/springboot/lib/javax.persistence.jar!/javax/persistence/Table.class
  •     jar:file:/C:/Users/jiayou/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/Table.class

It was loaded from the following location:

  •     file:/C:/practice/springboot/lib/javax.persistence.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.Table


2、分析

看了這個鏈接 NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index,找到了原因:

當前項目和倉庫同時提供了Table.class的類路徑。

3、解決

在當前項目的庫中刪除下面的jar包:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章