java - Karaf OSGi 配置抛出 ResolutionException: Unable to resolve root: missing requirements [root] osgi.identity;
问题描述
我正在创建一个将在 Karaf 上运行的 Spring Boot 应用程序。我试图在 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$1(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 仓库。我正在使用 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
推荐阅读
- python - 如果属性不存在,如何将属性插入到文档中?
- polymer - 聚合物捆绑器不输出带有自定义捆绑包的 node_modules 文件夹
- excel - .Find方法不按顺序搜索
- unity3d - 对象传递时的文本写入
- r - 比较 R 中的层次聚类
- php - 如何拒绝直接访问网站文件但允许网站文件通过包含'file.php'相互访问?
- java - 将 java 时钟传递给控制器(映射类)
- php - 如何将 Excel 文件中的下标和上标导入 mySQL 数据库?
- javascript - 为什么此处显示参考错误“未定义 valuesIdx”?
- javascript - 无法从 php 输出的 html 执行 javascript onclick 事件