How can I use Maven to get the latest Hibernate release?

I am having trouble getting the latest release of Hibernate via Maven dependency. It appears that the latest I can fetch from a Maven central repository is 3.2.6.GA, and I am interested in using 3.3.2.GA, which is the latest release shown on the hibernate.org site. When I modify my hibernate dependency to this latest version in my project's pom.xml I get the following error when I run a Maven build:

Missing:
----------
1) org.hibernate:hibernate:jar:3.3.2.GA

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -D
version=3.3.2.GA -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 -Dve
rsion=3.3.2.GA -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[
id]

Once I do that I continue to get errors indicating that I need to add a javassist dependency, then I need to update my hibernate-validator dependency, which also needs to be installed locally, and at that point I stopped and looked around to see if there is a better way, maybe pointing Maven to a JBoss/Hibernate repository, etc. This really seems to be a headache compared to other significant open cource packages that I use such as Spring or JUnit -- when there's a new version released all I do is update the version number in the dependency element and it just works.

I have tried adding the below repository declaration into my pom.xml but with no joy:

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

I searched Google and didn't find much which helps. Can someone suggest the most straight-forward way of going about using the latest releases of hibernate or hibernate-core (3.3.2.GA), hibernate-validator (3.1.0), and hibernate-annotations (3.4.0)?


JBoss have started synchronising their own repo with Maven central as posted on the JBoss community blog , therefore hibernate artifacts are now available without the need to add the JBoss repository to your pom.xml or repository manager.

Search result for hibernate-core:

hibernate-core的搜索结果

To add the Hibernate Core 3.6.3 to your project, just add the following snippet to your pom:

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

You're having problems because org.hibernate:hibernate:3.3.2.GA is an aggregator POM used to build the rest of the modules, it isn't actually a jar. It looks like a refactoring happened after 3.2.7 and that's thrown people off. For reference this blog entry hints at problems they've had promoting Hibernate to central and may explain the change.

If you look in the JBoss repository, you'll see that the hibernate modules for 3.3.2.GA are hosted, they're just hosted as individual artifacts, hibernate-core, hibernate-ehcache etc. So your repository declaration is correct, you just need to fine tune the dependency declarations to take the change into account.

The JBoss repository hosts hibernate-annotations-3.4.0.GA, hibernate-validator-3.1.0.GA, and hibernate-core-3.3.2.GA amongst others. Try adding the specific artifacts to your POM and use the JBoss repository as you've already declared.

There is also a hibernate-dependencies pom that provides transitive dependencies to the majority of hibernate artifacts (including core). So the simplest thing to do would be to replace your existing hibernate dependency declaration with hibernate-dependencies

Your dependencies would end up like this...

<dependencies>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-dependencies <!--or hibernate-core--></artifactId>
    <version>3.3.2.GA</version>
    <type>pom</type>
    <!--hibernate-dependencies is a pom, not needed for hibernate-core-->
  </dependency>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <version>3.4.0.GA</version>
  </dependency>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>3.1.0.GA</version>
  </dependency>
  ...
  <!--any other hibernate deps not inherited transitively-->

To make your life simpler you could define all these hibernate dependencies in a project say called (hibernate-all), then reference that single project for all your projects that use hibernate (of course it would be nice if the hibernte team provided that project anyway).


It's frustrating, but the newer versions just aren't there, and haven't been for a long time. The irony is that the Hibernate artifacts have some fairly intricate inter-dependencies and well-documented minimum versions of those dependencies, which would be ideally represented as a Maven POM. Instead, we have to download the binaries ourselves and try and express them locally.

链接地址: http://www.djcxy.com/p/29646.html

上一篇: Maven检查存储库中的更新依赖关系

下一篇: 我如何使用Maven获取最新的Hibernate版本?