如何使用Maven获取最新的Hibernate版本?

Jam*_*ams 35 dependencies maven-2 hibernate pom.xml

我无法通过Maven依赖获取最新版本的Hibernate.看来我可以从Maven中央存储库获取的最新版本是3.2.6.GA,我对使用3.3.2.GA很感兴趣,这是hibernate.org网站上显示的最新版本.当我在项目的pom.xml中将我的hibernate依赖项修改为最新版本时,运行Maven构建时出现以下错误:

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]
Run Code Online (Sandbox Code Playgroud)

一旦我这样做,我继续得到错误,表明我需要添加一个javassist依赖,然后我需要更新我的hibernate-validator依赖,这也需要在本地安装,然后我停下来,环顾四周,看看是否有一种更好的方法,可能将Maven指向JBoss/Hibernate存储库等等.与我使用的其他重要的开放源代码包(例如Spring或JUnit)相比,这真的很令人头疼 - 当我发布了新版本时do是更新依赖元素中的版本号,它只是工作.

我已经尝试将以下存储库声明添加到我的pom.xml中,但没有任何乐趣:

<repositories>
    <repository>
        <id>jboss</id>
        <url>http://repository.jboss.org/maven2</url>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)

我搜索谷歌并没有找到太多帮助.有人可以提出最直接的方式来使用最新版本的hibernate或hibernate-core(3.3.2.GA),hibernate-validator(3.1.0)和hibernate-annotations(3.4.0)?

Rob*_*anu 36

JBoss已经开始在JBoss社区博客上发布与Maven central同步他们自己的repo ,因此hibernate现在可以使用工件而无需将JBoss存储库添加到您的pom.xml或存储库管理器.

搜寻结果:hibernate-core:

搜索结果为hibernate-core

要将Hibernate Core 3.6.3添加到您的项目中,只需将以下代码段添加到您的pom:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.6.3.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)


Ric*_*ler 16

你有问题,因为org.hibernate:hibernate:3.3.2.GA是一个聚合器POM,用于构建其余的模块,它实际上不是一个jar.它看起来像是在3.2.7之后发生的重构,这让人们失望了.作为参考,这篇博客文章暗示了他们将Hibernate推广到中心的问题,并可能解释这一变化.

如果你查看JBoss存储库,你会看到3.3.2.GA的hibernate模块托管的,它们只是作为单独的工件,hibernate-core,hibernate-ehcache等托管.所以你的存储库声明是正确的,您只需要微调依赖性声明以将更改考虑在内.

JBoss存储库包含hibernate-annotations-3.4.0.GA,hibernate-validator-3.1.0.GAhibernate-core-3.3.2.GA等.尝试将特定工件添加到POM中,并使用已经声明的JBoss存储库.

还有一个hibernate-dependencies pom,它为大多数hibernate工件(包括core)提供传递依赖.因此,最简单的方法是用hibernate-dependencies替换现有的hibernate依赖声明

你的依赖关系会像这样结束......

<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-->
Run Code Online (Sandbox Code Playgroud)

为了让你的生活变得更简单你可以在一个名为hibernate-all的项目中定义所有这些hibernate依赖项,然后为所有使用hibernate的项目引用单个项目(当然,如果hibernte团队提供该项目,那将会很好).


Sal*_*dur 0

存储库中缺少 jar,也许这就是最新的 hibernate 版本不在主存储库中的原因