如何通过 Maven2 pom.xml 获取 Hibernate + javax.persistence
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3905738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get Hibernate + javax.persistence via Maven2 pom.xml
提问by Tim
I am a newbie with Maven2 and I write a pom.xml. Now I want to get Hibernate and javax.persistence to resolve this:
我是 Maven2 的新手,我写了一个 pom.xml。现在我想让 Hibernate 和 javax.persistence 来解决这个问题:
import javax.persistence.Entity;
...
import org.hibernate.annotations.Fetch;
...
What needed to be done? I wrote in my pom.xml:
需要做什么?我在我的 pom.xml 中写道:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.5.6-Final</version>
</dependency>
But I get an error (I already get some other dependencies, but Hibernate does not work):
但是我得到一个错误(我已经得到了一些其他的依赖,但是 Hibernate 不起作用):
11.10.10 13:19:53 MESZ: Refreshing [/testProject/pom.xml]
11.10.10 13:19:54 MESZ: Missing artifact org.hibernate:hibernate:jar:3.5.6-Final:compile
11.10.10 13:19:54 MESZ: Maven Builder: AUTO_BUILD
11.10.10 13:19:55 MESZ: Maven Builder: AUTO_BUILD
So, what's wrong here? Why it does not know the artifact?
那么,这里有什么问题呢?为什么它不知道神器?
Thank you in advance & Best Regards.
提前致谢并致以最诚挚的问候。
采纳答案by Pascal Thivent
Declare the JBoss repository:
声明 JBoss 存储库:
<project>
...
<repositories>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
...
</repositories>
...
</project>
And then the following dependency:
然后是以下依赖项:
<project>
...
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.6-Final</version>
</dependency>
...
</dependencies>
...
</project>
And that's all your need, the other dependencies will be pulled transitively.
这就是您的全部需要,其他依赖项将被传递。