Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Hibernate 3.5.x to a maven pom.xml build

I added the JBoss Maven repo to my pom.xml file like this...

 <repositories>
        <repository>
            <id>jboss</id>
            <url>http://repository.jboss.org/maven2/</url>        
        </repository>
    </repositories>

And I added Hibernate itself like this...

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.5.1-Final</version>
    </dependency>

But when I try to build my application I see this error....

Downloading: http://repository.jboss.org/maven2//org/hibernate/hibernate/3.5.1-Final/hibernate-3.5.1-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.1-Final' in repository jboss (http://repository.jboss.org/maven2/)
Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate/3.5.1-Final/hibernate-3.5.1-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.1-Final' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.hibernate:hibernate:jar:3.5.1-Final

  Try downloading the file manually from the project website.

  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.hibernate -DartifactId=hibernate -Dversion=3.5.1-Final -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) stakeholdersupdate:stakeholdersupdate:war:1.0
    2) org.hibernate:hibernate:jar:3.5.1-Final

----------
1 required artifact is missing.
like image 821
benstpierre Avatar asked Jun 10 '10 21:06

benstpierre


People also ask

Does hibernate support Maven?

It is highly recommended to consume Hibernate ORM artifacts through a dependency management tool. The artifacts can be found in Maven's central repository but are released first in the JBoss maven repository.


1 Answers

As seanizer mentioned, the org.hibernate:hibernate:pom:3.5.1-Final artifact is an aggregating modules of type pom (it aggregates the Hibernate Core modules). So you could indeed depend on it by specifying a <type>pom</type>. But I would personally declare a dependency on the wanted module, for example for Hibernate Entity Manager:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-entitymanager</artifactId>
  <version>3.5.1-Final</version>
</dependency>

Or for Hibernate Core:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>3.5.1-Final</version>
</dependency>
like image 121
Pascal Thivent Avatar answered Oct 18 '22 07:10

Pascal Thivent