如何使用Karaf上频繁的本地快照捆绑部署? [英] How to work with frequent local snapshot bundle deployments on Karaf?

查看:105
本文介绍了如何使用Karaf上频繁的本地快照捆绑部署?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定在OSGI和Karaf之上构建一个应用程序-我真的很喜欢这个东西.但是,我在本地开发计算机上的日常部署有些麻烦.我的意思是..我进行了更改,然后想在我的本地Karaf实例上对其进行测试.每小时可能会发生几次.

I decided to build an application on top of OSGI and Karaf - I really like this stuff. However, I'm struggling a bit with a daily deployment on my local, development machine. I mean.. I make a change and then I would like to test it on my local Karaf instance. And it can happen like couple times per hour.

我现在的操作方式是创建一个JAR包的Maven构建,然后将其复制到Karaf的deploy目录中.我认为这一点都不优雅.

The way I'm doing it now is a maven build that creates a JAR bundle and then it's copied into the Karaf's deploy directory. I think that it isn't elegant at all.

我试图找到一种解决方法(谷歌).我阅读了有关Karaf的功能的信息,但似乎尽管它是部署整个应用程序的一种不错的机制,但它并不能解决我的问题.据我所知,它不会检查SNAPSHOT jar的新版本是否在我的本地Maven存储库中出现,对吗?

I was trying to find a way around (google). I read about Karaf's features but it seems that despite the fact that it is a nice mechanism for deploying whole app, it doesn't solve my problem. As I understand it right, it does not check whether new version of my SNAPSHOT jar appeared in my local maven repo, right?

推荐答案

使karaf更新机制起作用的关键是从maven进行部署,而不是使用deploy文件夹. 像这样安装捆绑包:

The key to make the update mechanism of karaf work is to deploy from maven instead of using the deploy folder. Install you bundle like this:

install -s mvn:groupid/artifactID/version

install -s mvn:groupid/artifactID/version/typeOfMavenArtifact

第二个对于安装例如战争/蜡像文物很有用.可以在此处找到完整的Maven协议规范.

Second one is useful for installing for example war/wab artifacts. Full maven protocol specification can be found here.

然后,Karaf知道捆绑包的来源.您也可以使用la -u进行检查.这使karaf显示更新位置,该位置现在应该是maven uri.您不会认为所有karaf捆绑包都具有这样的更新位置.

Then Karaf knows where the bundle came from. You can also check this using la -u. This makes karaf show the update location which now should be a maven uri. You will not that all karaf bundles have an update location like this.

当您现在使用maven创建项目的新版本时,它将最终出现在您本地的maven存储库中. 然后只需运行

When you now create a new build of your project using maven it will end up in you local maven repository. Then simply run

update <bundleid>

这使karaf检查更新位置(在您的情况下,您是本地Maven存储库)并从那里重新加载捆绑软件.

This makes karaf check the update location (in your case you local maven repo) and reload the bundle from there.

您甚至可以通过以下方式进一步实现自动化

You can even further automate this by using

dev:watch

或适用于karaf 3 +

or for karaf 3+

bundle:watch

这将使karaf检查您的Maven存储库中是否已部署了SNAPSHOT捆绑软件,并自动将其重新部署.

This will make karaf check you maven repo for changes in SNAPSHOT bundles it has deployed and automatically redeploy these.

这与远程调试一起也可以很好地工作.使用

This also works very well together with the remote debugging. Use

export KARAF_DEBUG=true

在开始卡拉夫之前.然后它将在端口5005上侦听调试器.

before starting karaf. It then will listen for a debugger on port 5005.

然后,您可以在同一端口上启动远程调试Eclipse会话,并在karaf中很好地调试应用程序.即使您使用上述方法之一更改捆绑包,此方法也能很好地工作.因此,您可以调试,查找问题,更改代码,构建并使用更改后的版本继续进行调试.

You can then start a remote debug eclipse session on the same port and nicely debug your application in karaf. This works very well even if you change your bundle using one of the approaches above. So you can debug, find your problem, change the code, build and continue debugging with the changed version.

当我在karaf代码库中工作时,我也会经常使用它,因为它也适用于大多数karaf自己的捆绑软件.

I also use this frequently when I work at the karaf code base itself as this also works for most of karaf's own bundles.

这篇关于如何使用Karaf上频繁的本地快照捆绑部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆