Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Hibernate + javax.persistence via Maven2 pom.xml

I am a newbie with Maven2 and I write a pom.xml. Now I want to get Hibernate and javax.persistence to resolve this:

import javax.persistence.Entity;
...
import org.hibernate.annotations.Fetch;
...

What needed to be done? I wrote in my 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):

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.

like image 779
Tim Avatar asked Oct 11 '10 11:10

Tim


People also ask

How do I add Hibernate dependencies in POM XML?

Then, install it using the command: mvn install:install-file -DgroupId=org. hibernate -DartifactId=hibernate -Dversion=3.5. 1-Final -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.


1 Answers

Declare the JBoss repository:

<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.

like image 109
Pascal Thivent Avatar answered Nov 15 '22 19:11

Pascal Thivent