JPA 2.0 API maven artifact

依然范特西╮ 提交于 2019-12-03 10:33:44
Pascal Thivent

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.

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.

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.

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