【问题标题】:I am confused with maven dependencies: "org.eclipse.persistence.jpa" and "org.hibernate"我对 Maven 依赖项感到困惑:“org.eclipse.persistence.jpa”和“org.hibernate”
【发布时间】:2017-04-21 08:31:02
【问题描述】:

我有一个使用 Maven 的 Spring MVC 项目。 我使用 Spring-data-jpa 作为我的依赖项之一:

  <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.10.5.RELEASE</version>
    </dependency>

Spring-data-jpa 提供了 api。 因此,我需要添加另一个实现 jpa 的依赖项。但是,我很困惑:

<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.jpa</artifactId>
    <version>2.6.4</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.2.2.Final</version>
</dependency>
<dependency>
    <groupId>org.apache.pdfbox</groupId>
    <artifactId>pdfbox</artifactId>
    <version>2.0.4</version>
</dependency>

什么是eclipse.persistence?和休眠的区别? 请帮忙!

【问题讨论】:

  • (与您的问题无关)PDFBox 为 2.0.5。
  • spring-data-jpa 不提供 API。它是一个包装器,使我们能够以简单简洁的方式编写查询。 jpa 是 API 规范。 Hibernate 是它的实现之一。

标签: java spring hibernate maven jpa


【解决方案1】:

Eclipse Persistence (EclipseLink) 和 Hibernate 都是 Java Persistence API 的实现,每个都有自己的额外功能,并且通常都有自己的错误。就速度而言,与其他实现相比,它们彼此非常相似。

每个持久性单元中只使用一个,在META-INF/persistence.xml 中定义。看看你的,在 persistence-unit->provider 节点内,你会找到使用的类。
如果它以org.hibernate 开头,那么您可以安全地删除 eclipse 依赖项。
如果以org.eclipse开头,可以去掉hibernate依赖。
如果您有多个持久性单元,每个都可以使用不同的实现/提供者。

【讨论】:

  • 是的,它们非常相似,但是 eclipselink 的权重更轻。
猜你喜欢
  • 1970-01-01
  • 2012-08-19
  • 2016-03-14
  • 1970-01-01
  • 1970-01-01
  • 2015-10-08
  • 1970-01-01
  • 2021-01-25
相关资源
最近更新 更多