Java 未解析捆绑包,因为在karaf中存在使用约束冲突

Java 未解析捆绑包,因为在karaf中存在使用约束冲突,java,osgi,bundle,apache-karaf,Java,Osgi,Bundle,Apache Karaf,如何克服此链依赖性问题。? Error executing command: Error executing command on bundles: Error starting bundle 429: Could not resolve module: com.sample.eventhistory [429] Bundle was not resolved because of a uses contraint violation. org.osgi.service.

如何克服此链依赖性问题。?

Error executing command: Error executing command on bundles:
        Error starting bundle 429: Could not resolve module: com.sample.eventhistory [429]
  Bundle was not resolved because of a uses contraint violation.
  org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"] because it exports package 'com.sample.restenquiry.exceptions' and is also exposed to it from resource com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"] via the following dependency chain:

 

  com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"]
    import: (osgi.wiring.package=com.sample.restutil.impl)
     |
    export: osgi.wiring.package=com.sample.restutil.impl; uses:=com.sample.restservice
  rest [osgi.identity; osgi.identity="edmexporest"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"]
    import: (&(osgi.wiring.package=com.sample.restservice)(&(version>=1.90.0)(!(version>=2.0.0))))
     |
    export: osgi.wiring.package: com.sample.restservice; uses:=com.sample.restenquiry.exceptions
    export: osgi.wiring.package=com.sample.restenquiry.exceptions
  com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"]

部署捆绑包时,服务未提交。相反,在karaf控制台中获取上述错误时,OSGi允许导出相同的包,只要版本号不同。在这种情况下,两个包导出的包+版本相同


一个好的做法是将接口和异常放在一个包(即服务api)中,然后使用者包和提供者包都可以导入这些包,但不需要使用者直接依赖提供者。

在将Apache felix迁移到DS实现[osgi]时,我遇到了这个问题。我在pom.xml@mattpavolovich中使用maven bundle插件版本3.2.0