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

我无法通过Maven依赖关系获取最新版本的Hibernate。 看来最新的我可以从Maven中央仓库获取3.2.6.GA,而且我有兴趣使用3.3.2.GA,它是hibernate.org站点上显示的最新版本。 当我在我的项目的pom.xml中将我的hibernate依赖项修改为最新版本时,我运行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] 

一旦我这样做,我继续得到错误,指示我需要添加一个javassist依赖项,然后我需要更新我的hibernate-validator依赖项,这也需要本地安装,在那一点上,我停下来,看看周围,看看是否有一个更好的方法,也许可以将Maven指向JBoss / Hibernate存储库等等。与我使用的其他重要的开源软件包(比如Spring或者JUnit)相比,这真的很让人头痛 – 当我发布新版本的时候, do是更新dependency元素中的版本号,它只是起作用。

我已经尝试将下面的存储库声明添加到我的pom.xml,但没有喜悦:

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

我search了谷歌,并没有find太多的帮助。 有人可以build议最直接的方式去使用最新版本的hibernate或hibernate-core(3.3.2.GA),hibernate-validator(3.1.0)和hibernate-annotations(3.4.0)吗?

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

search结果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> 

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

如果你看看JBoss仓库 ,你会发现3.3.2.GA的hibernate模块托pipe的,它们只是作为独立的工件,hibernate-core,hibernate-ehcache等托pipe。所以你的仓库声明是正确的,你只需要微调依赖声明来考虑这个变化。

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

还有一个hibernate-dependencies pom为大多数hibernate构件(包括core)提供传递依赖性。 所以最简单的事情就是用hibernate-dependenciesreplace现有的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--> 

为了简化你的生活,你可以在一个名为hibernate-all的项目中定义所有这些hibernate依赖项,然后为所有使用hibernate的项目引用这个项目(当然,如果hibernte团队提供了这个项目, )。

这是令人沮丧的,但新版本不在那里,而且已经很久没有。 具有讽刺意味的是,Hibernate构件具有一些相当复杂的内部依赖关系,并且具有良好logging的这些依赖关系的最低版本,这将被理想地表示为Maven POM。 相反,我们必须自己下载二进制文件,并在本地进行expression。

你可以在你的pom.xml中使用依赖

 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.6.ga</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.3.1.GA</version> </dependency> 

自从很久以来,这个问题已经过时了:所有的Hibernate发行版都可以在Maven中心使用,

查看www.hibernate.org获取最新的Maven坐标(不要相信IDE的build议)。

这个jar文件在版本库中是不存在的,也许这就是最新的hibernate版本不在主repoistory中的原因

新的这个和玩它。 我没有一个完整的解决scheme但是:

似乎我能够通过包含http://repository.jboss.com/maven3/而不是maven 2来解决一些依赖关系。

对于那些仍然存在问题的人来说,可以作为最后一根稻草从maven站点下载缺失的文件,例如,浏览:

http://repo1.maven.org/maven2/org/hibernate/hibernate-core/3.6.8.Final/

(是的,我试图设置这个和其他合理的path作为存储库的来源,但没有成功…)

要将这个jar安装到你的maven版本中,请执行如下操作:

 mvn install:install-file -Dfile=path/to/jar/hibernate-core-3.6.8.Final.jar -DgroupId=org.hibernate -DartifactId=hibernate-core -Dversion=3.6.8-Final -Dpackaging=jar 

参考: http : //maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

对不起,只是意识到这是多余的,但希望有一些看到额外的可能的URL有帮助。 – JB