How to install Hibernate 5 into Apache Karaf v4

雨燕双飞 提交于 2019-12-04 16:24:53

Latest hibernate-release comes Karaf ready already:

If you download the hibernate-release-5.0.5.Final.zip from hibernate's page (http://sourceforge.net/projects/hibernate/files/hibernate-orm/5.0.5.Final/hibernate-release-5.0.5.Final.zip/download) and decompress the file, you will see an osgi folder. There you can find an already prepared feauture: hibernate-osgi-5.0.5.Final-karaf.xml. You can just copy it to Karaf's deploy folder and then execute:

feature:install hibernate-orm

It should be installed without any problem.

Another way to install hibernate 5.0.5 feature is to add a repo to features with the command:

feature:repo-add command.

Here you can see the list of hibernate's features and the one I have installed:

karaf@root()> feature:list | grep hibernate
hibernate                     | 3.3.2.GA         |          | Uninstalled | enterprise-4.0.3         | Hibernate 3.x JPA persistence engine support
hibernate                     | 4.2.15.Final     |          | Uninstalled | enterprise-4.0.3         | Hibernate 4.2.x JPA persistence engine support
hibernate-envers              | 4.2.15.Final     |          | Uninstalled | enterprise-4.0.3         | Hibernate Envers 4.2.x
hibernate                     | 4.3.6.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate 4.3.x JPA persistence engine support
hibernate-envers              | 4.3.6.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate Envers 4.3.x
hibernate-validator           | 5.0.3.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate Validator support
hibernate-orm                 | 5.0.5.Final      | x        | Started     | hibernate-osgi           | Combines all Hibernate core dependencies and requ
hibernate-envers              | 5.0.5.Final      |          | Uninstalled | hibernate-osgi           | Feature for easily adding Envers support to hiber
hibernate-infinispan          | 5.0.5.Final      |          | Uninstalled | hibernate-osgi           | Feature for easily adding Infinispan-based cachin
hibernate-ehcache             | 5.0.5.Final      |          | Uninstalled | hibernate-osgi           | Feature for easily adding Ehcache-based caching s
karaf@root()>

Run the following commands on Karaf shell to get Hibernate 5.1.0.Final working on Karaf 4.0.x:

feature:repo-add mvn:org.hibernate/hibernate-osgi/5.1.0.Final/xml/karaf
feature:install hibernate-orm

Hibernate 5 already provides a feature that is also available from maven central. Recent karaf versions provide a nice shortcut to install such features:

feature:repo-add hibernate 5.0.5.Final
feature:install hibernate-orm

So there is no need to manually download the hibernate zip. If you build your own feature that needs hibernate 5 then you need to provide a element in it that points to the full hibernate feature url.

mvn:org.hibernate/hibernate-osgi/5.0.5.Final/xml/karaf
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!