为javax.persistence编写Maven依赖项

qyuhtwio  于 2022-12-02  发布在  Java
关注(0)|答案(3)|浏览(437)

有人能帮我写javax.persistence的依赖关系吗?我已经在谷歌上搜索过了,但是没有任何效果。
我的bumped into this page提供了一些关于如何编写依赖项的细节,但是我无法编写它。有人能帮我吗?

sbtkgmzw

sbtkgmzw1#

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.

6yt4nkrj

6yt4nkrj2#

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

a11xaf1n

a11xaf1n3#

更新链接:https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api/2.2在这里。
Maven依赖关系如下:

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

相关问题