我使用构建所有捆绑包maven-bundle-plugin
,经过一些测试后,pax:provision
我发现它正在Import-Package=org.osgi.framework;version="[1.8,0)"
所有捆绑包上创建一个,并且在 Felix 中安装捆绑包时,我的所有捆绑包都未解决,因为org.osgi.framework.BundleException: Unresolved constraint in bundle com.domain.mybundle [55]: Unable to resolve 55.0: missing requirement
[55.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0)))
.
maven-bundle-plugin
如果我对该包没有直接依赖关系,为什么要创建此标头。我还尝试添加依赖项:
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>4.6.0</version>
</dependency>
它仍然使用该版本1.8.0
。知道为什么吗?
更新
再次检查,捆绑包确实使用org.osgi.framework
了 Activator 中的 。但是这个类org.osgi.framework.BundleActivator
来自捆绑:
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
再说一遍,为什么不maven-bundle-plugin
使用版本4.3.1
而不是1.8.0
?在其他捆绑包中,它使用 version 1.6.2
。
2015 年 3 月 20 日更新
这是我执行后收到的异常mvn pax:provision
org.osgi.framework.BundleException: Unresolved constraint in bundle org.classdomain.per
sistence [47]: Unable to resolve 47.0: missing requirement[47.0] osgi.wiring.package;
(&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0)))ERROR:
Bundle org.classdomain.persistence [47] Error starting file:bundles/org.classdomain.per
sistence_0.1.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle
org.classdomain.persistence [47]: Unable to resolve 47.0: missing requirement [47.0] o
sgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(versio
n>=2.0.0))))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
at java.lang.Thread.run(Thread.java:745)
当然,似乎这个异常只在使用时发生mvn pax:provision
,如果我在独立的 Felix 实例中安装相同的包,那么一切都按预期工作。