# Hibernate 框架查询运行的 javax.persistence.Table.indexes() 错误

**URL:** <https://www.isharkfly.com/t/hibernate-javax-persistence-table-indexes/13814>\
**Category:** 程序语言\
**Tags:** hibernate\
**Created:** [November 19, 2021, 6:59pm UTC](https://www.isharkfly.com/t/hibernate-javax-persistence-table-indexes/13814 "2021-11-19T18:59:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [November 19, 2021, 6:59pm UTC](https://www.isharkfly.com/t/hibernate-javax-persistence-table-indexes/13814/1 "2021-11-19T18:59:12Z")

</div>

Hibernate 项目在执行测试的时候遇到异常：

```auto
Hibernate 5 - java.lang.NoSuchMethodError: javax.persistence.Table.indexes()

```

## 问题和解决

出现上面问题的主要原因是你的项目中可能出现了 2 个 JPA 的包，导致了冲突。

你需要检查你项目中的依赖，看有没有这个问题。

- hibernate-jpa-2.0-api-1.0.0.Final.jar
- javax.persistence-api-2.2.jar

javax.persistence.Table.indexes 这个特性是在 JPA 2.1 中添加的。
