Karaf OSGi 配置抛出 ResolutionException:无法解析 root:缺少要求 [root] osgi.identity;

Karaf OSGi config throws ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity;

我正在创建一个 Spring 引导应用程序,它将 运行 在 Karaf 上。我试图在 Karaf 中公开项目配置属性,以便能够使用 config:property-set 更改属性而无需重新部署应用程序。

所以我已经设法配置我的 karaf 功能以将属性公开给 Karaf 但我正在尝试创建一个 OSGi 组件以便能够在 属性 更改为 config:property 时获取更新-set.

我在尝试安装 .kar 文件时遇到的错误如下:

[[A2019-05-19T23:09:32,926 | INFO  | pipe-kar:install file:/Users/nikos/development/interlink/thirdParty/osgi-karaf-spring-boot-demo/osgi-spring-boot-demo-features/target/osgi-spring-boot-demo-features-0.0.1-SNAPSHOT.kar | KarServiceImpl                   | 35 - org.apache.karaf.kar.core - 4.1.3 | Added feature repository 'mvn:com.nemesis/osgi-spring-boot-demo-features/0.0.1-SNAPSHOT/xml/features'
2019-05-19T23:09:32,927 | INFO  | pipe-kar:install file:/Users/nikos/development/interlink/thirdParty/osgi-karaf-spring-boot-demo/osgi-spring-boot-demo-features/target/osgi-spring-boot-demo-features-0.0.1-SNAPSHOT.kar | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.3 | Adding features: osgi-spring-boot-demo-feature/[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]
2019-05-19T23:09:32,995 | WARN  | pipe-kar:install file:/Users/nikos/development/interlink/thirdParty/osgi-karaf-spring-boot-demo/osgi-spring-boot-demo-features/target/osgi-spring-boot-demo-features-0.0.1-SNAPSHOT.kar | KarServiceImpl                   | 35 - org.apache.karaf.kar.core - 4.1.3 | Unable to install Kar feature osgi-spring-boot-demo-feature/0.0.1.SNAPSHOT
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=osgi-spring-boot-demo-feature; type=karaf.feature; version="[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]"; filter:="(&(osgi.identity=osgi-spring-boot-demo-feature)(type=karaf.feature)(version>=0.0.1.SNAPSHOT)(version<=0.0.1.SNAPSHOT))" [caused by: Unable to resolve osgi-spring-boot-demo-feature/0.0.1.SNAPSHOT: missing requirement [osgi-spring-boot-demo-feature/0.0.1.SNAPSHOT] osgi.identity; osgi.identity=com.nemesis.osgi-spring-boot-demo-bundle; type=osgi.bundle; version="[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve com.nemesis.osgi-spring-boot-demo-bundle/0.0.1.SNAPSHOT: missing requirement [com.nemesis.osgi-spring-boot-demo-bundle/0.0.1.SNAPSHOT] osgi.extender; filter:="(&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))"]]
    at org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42) ~[?:?]
    at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:391) ~[?:?]
    at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:377) ~[?:?]
    at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:349) ~[?:?]
    at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:218) ~[?:?]
    at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:291) ~[?:?]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1248) ~[?:?]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread(FeaturesServiceImpl.java:1147) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]

这是我的github repo。我正在使用 java 8 和 Maven 3.6,org.osgi.core 5.0.0,Karaf 4.1.3

有什么办法可以解决这个问题吗?使用@Component 和@Modified 从 Karaf 获取 属性 修改更新的正确方法是什么?

提前致谢!

该错误消息表示您缺少满足您的捆绑包要求之一的捆绑包。

您在这条长错误消息的末尾找到了缺少的要求:

(&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))

这意味着您缺少 osgi.component 型号的扩展器。

那么那里发生了什么?您在 类 中使用声明性服务注释。 Maven bundle 插件读取它们并为声明性服务创建 xml 以及上面扩展程序的要求。

所以这个要求可以帮助您在安装包时不会错过声明式服务运行时。

对于 karaf,解决方案是安装提供运行时的功能:

feature:install scr

您遇到上述错误是因为未安装依赖包或安装的包的版本不在范围内,

您可以在 karaf 终端中通过以下命令检查包是否已安装以及安装的版本是什么:

  la -l|grep "#bundle name"

其中包名称是您遇到错误的包,

有时可能只缺少一个包,但也有可能没有安装该功能,该功能只不过是一组包,

要检查该功能是否已安装,请使用以下命令:

feature:list|grep "#feature name" 

在这里,您可以安装该功能,它应该可以解决问题

feature:install scr