Writing Maven Dependency for javax.persistence

别来无恙 提交于 2020-01-31 22:40:28

问题


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?


回答1:


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.




回答2:


And add this dependency in your pom.xml:

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

That "Coping with Sun JARs" page might be a little outdated, this JAR is available in the Maven Central Repository



来源:https://stackoverflow.com/questions/8243077/writing-maven-dependency-for-javax-persistence

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