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

查看:18
本文介绍了如何在 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.

我现在做的方式是一个 maven 构建,它创建一个 JAR 包,然后将它复制到 Karaf 的部署目录中.我认为它一点也不优雅.

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 的功能,但似乎尽管它是部署整个应用程序的一个很好的机制,但它并没有解决我的问题.据我了解,它不会检查我的本地 Maven 存储库中是否出现了我的 SNAPSHOT jar 的新版本,对吗?

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

第二个对于安装例如 war/wab 工件很有用.可以在此处找到完整的 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.

您甚至可以使用

dev:watch

或 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

在开始karaf之前.然后它将侦听端口 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天全站免登陆