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
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:
- Restrictive license
- Naming convention
来源:https://stackoverflow.com/questions/3893857/jpa-2-0-api-maven-artifact