JPA 2.0 API maven artifact

 ̄綄美尐妖づ 提交于 2019-12-21 03:12:50

问题


I am using JPA 2.0 and my persistence provider is Hibernate; however, I'd like to just include a standard API from javax, but in central, there is no 2.0 artifact. I am currently using the Hibernate JPA 2.0 artifact, but I'd like to use something more standard.

Is this possible?

Thanks,

Walter


回答1:


I am currently using the Hibernate JPA 2.0 artifact, but I'd like to use something more standard

There is still no javax.persistence:persistence-api:jar:2.0 artifact from Sun/Oracle. Either use the full javax:javaee-api:jar:6.0 artifact if you want something from Sun/Oracle... or just stick with the interfaces provided by Hibernate, EclipseLink, OpenJPA, etc.




回答2:


As Ivan explains, there are no official Sunacle jars in Maven. However, it is quite often the case that an implementer of a given API will publish an artifact for that API (the API itself, rather than their implementation of it.

In the case of JPA 2.0, Hibernate publish org.hibernate.javax.persistence:hibernate-jpa-2.0-api, which contains just the javax.persistence classes, and no Hibernate-specific stuff.

My build.gradle therefore says:

dependencies {
    compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.0-api', version: '1.0.1.Final'
    runtime group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.1.4.Final'
}

Which puts Hibernate's release of the API on the compile classpath, and their implementation on the runtime classpath.




回答3:


Currently (Q4 2017) there is a javax.persistence-api available at maven central.

<dependency>
  <groupId>javax.persistence</groupId>
  <artifactId>javax.persistence-api</artifactId>
  <version>2.2</version>
</dependency>

The code is maintained in this github repo.




回答4:


The direct answer to your questions is: No, it's not possible. The longer version is given here: Apache > Maven > Guide to Coping with Sun JARs . A short summary of the longer answer:

There are (at least) two problems with publishing Sun/Oracle artifacts in central repository:

  1. Restrictive license
  2. Naming convention


来源:https://stackoverflow.com/questions/3893857/jpa-2-0-api-maven-artifact

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!