Writing Maven Dependency for javax.persistence

Illep picture Illep · Nov 23, 2011 · Viewed 59.5k times · Source

Can someone help me write the dependency for javax.persistence. I have googled it but nothing worked.

I bumped into this page that gives some details on how to write the dependency, but yet i am unable to write it. Can someone help me out?

Answer

LeChe picture LeChe · Nov 23, 2011

This is the one for javax.persistence:

<dependency>
   <groupId>javax.persistence</groupId>
   <artifactId>persistence-api</artifactId>
   <version>1.0.2</version>
   <scope>provided</scope>
</dependency>

and this is for the whole Java EE 6 stack:

<dependency>
   <groupId>javax</groupId>
   <artifactId>javaee-api</artifactId>
   <version>6.0</version>
   <scope>provided</scope>
</dependency>

Edit
Note that I specified a provided scope here, which means that your dependency is available at compile- and test-time, but will not be packaged into your artifacts. This is usually needed if you want to deploy your artifacts in an application server, since they provide their own implementation of the api.