Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
487 views
in Technique[技术] by (71.8m points)

dependencies - Where can I find a JPA2 Maven dependency?

I'm trying to build an implementation agnostic maven module which relies on JPA2. Unfortunately, the only Maven JPA dependency is JPA1 based, and consequently, I cannot use EntityManager.detach() method as that is a JPA2 option only.

Ideally, I'd love to be able to specify my javax.persistence dependency in my Pom, and require the app/container to supply the JPA2 implementation. Unfortunately, I cannot find any such dependency.

Is my only choice at this point to declare hibernate-jpa-2.0-api 1.0.0.FINAL as a provided dependency?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I know this is a quite old post, if you want to go agnostic from the implementation, then you should use the Java EE API dependency instead.

Just add to your POM:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>${jee.version}</version>
    <scope>provided</scope>
</dependency>

Where the ${jee.version} is your desired Java EE version. I'm currently using 7.0. It has all EJB, JPA and JSF APIs dependencies.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...