且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

线程"main"中的异常java.lang.NoSuchMethodError:javax.persistence.Table.indexes()[Ljavax/persistence/Index;

更新时间:2023-09-20 22:34:22

您需要将hibernate-jpa-2.1-api-1.0.0.Final.jar添加到类路径中.

You need to add hibernate-jpa-2.1-api-1.0.0.Final.jar to the classpath.

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.1-api</artifactId>
    <version>1.0.0.Final</version>
</dependency>

Table#indexes()方法已在版本2.1中添加.因此,您在类路径中使用了@Table批注的jar(例如2.0版示例)不正确.它可以位于应用程序服务器或Web容器的默认lib文件夹中.

Table#indexes() method was added in the version 2.1. So you have an incorrect jar (for an example version 2.0) with the @Table annotation in the class path. It can be in the default lib folder of the application server or the web container.

解决方案

persistence-api-1.0.jar中存在错误的@Table批注.因此,需要从类路径中删除此jar. hibernate-jpa-2.1-api-1.0.0.Final.jar具有所有带有persistence-api-1.0.jar的注释.

An incorrect @Table annotation resides in the persistence-api-1.0.jar. So it is need to delete this jar from the class path. hibernate-jpa-2.1-api-1.0.0.Final.jar has all annotations which has persistence-api-1.0.jar.