当前位置: 首页 > 知识库问答 >
问题:

Pax Exam:通过捆绑包和包装捆绑包解决项目依赖关系

谷梁俊楚
2023-03-14

我知道这个答案:Pax考试:提供具有所有依赖项的捆绑包,但当我必须包含作为我项目外部捆绑包一部分的捆绑包时,感觉我做错了什么。

这是我得到的错误:

java.lang.Exception: Could not start bundle wrap:mvn:org.apache.cxf/cxf-bundle-jaxrs/2.7.14 in feature(s) test-dependencies-0.0.0: Unresolved constraint in bundle org.apache.cxf.bundle-jaxrs [80]: Unable to resolve 80.0: missing requirement [80.0] osgi.wiring.package; (&(osgi.wiring.package=com.ctc.wstx.stax)(version>=4.4.0)(!(version>=5.0.0)))

下面是我的pax考试的配置代码:

@Configuration
public Option[] config() {
    MavenArtifactUrlReference karafUrl = maven()
        .groupId("org.apache.karaf")
        .artifactId("apache-karaf")
        .version(karafVersion())
        .type("tar.gz");
    MavenUrlReference karafStandardRepo = maven()
        .groupId("org.apache.karaf.features")
        .artifactId("standard")
        .classifier("features")
        .version(karafVersion())
        .type("xml");
    return new Option[] {
        // KarafDistributionOption.debugConfiguration("5005", true),
        karafDistributionConfiguration()
            .frameworkUrl(karafUrl)
            .unpackDirectory(new File("target/exam"))
            .useDeployFolder(false),
        keepRuntimeFolder(),
        KarafDistributionOption.features(karafStandardRepo , "scr"),

        //**Do I seriously need to do this?**
        wrappedBundle(mavenBundle("org.codehaus.woodstox", "wstx-lgpl")).noStart(),
        //**Why am I doing this?**
        wrappedBundle(mavenBundle("org.apache.cxf", "cxf-bundle-jaxrs").version("2.7.14")).noStart(),
        //**Some of my bundles use this so I guess this makes sense**
        wrappedBundle(mavenBundle("org.apache.commons", "commons-lang3")),
        mavenBundle("com.company.project", "common-core").versionAsInProject().start(),
        mavenBundle("com.company.project", "common-properties", "1.3.1").start(),
        mavenBundle("com.company.project", "rev-common-core", "1.3.1").start(),
        mavenBundle("com.company.project", "rev-common-properties", "1.3.1").start(),
        mavenBundle("com.company.project", "maintenance-core", "1.3.1").start(),
   };
}

所以我的问题是:为什么我会遇到关于未解决约束的错误,我是否必须包括外部捆绑包,以及我需要做什么才能让我的测试运行?

共有1个答案

阴元青
2023-03-14

是的,你必须包括所有需要的捆绑包,Karaf容器是空的,你必须提供测试中需要的所有捆绑包。

您可以为要测试的模块创建一个功能,以提供所有必需的捆绑包。然后你可以在测试中使用它,例如:

KarafDistributionOption.features("mvn:group/artifact-id/version/xml", "feature-name")
 类似资料:
  • 以前部署的JDOM的OSGi包究竟是如何解决这些相同的依赖关系的?它们从来没有在捆绑进口包中列出?此外,如果我试图将这些作为项目的依赖项包含并嵌入它们,只会加剧问题。救命啊!

  • 我是OSGi的新手。我正在使用Apache Felix。我已经构建了一个捆绑包,并且具有依赖性。当我尝试使用启动它会给我这个错误。 org . OSGi . framework . bundle exception:无法解析lk . ucsc . research . belly runner[20](R 20.0):缺失需求[lk . ucsc . research . belly runner

  • 目前,要为Pax考试设置配置,我发现需要包含所有依赖项。比如说 但是由于依赖于,这感觉像是重复的信息。Pax Exam是否可能在不明确添加的情况下发现需要?

  • 问题内容: 编辑:Symfony最佳做法回答了我的大部分问题。 关于我的Symfony2应用程序,我有几个问题。 它将有一个前端和一个后端,并且它们将使用一些通用代码(例如日期显示器,分页器,一些经常使用的模板等)。 因此,我创建了一个FrontendBundle和一个BackendBundle,它们分别包含各自的布局。第一个问题:为前端和后端创建捆绑包(这是甚至没有控制器的“通用”捆绑包)的优良

  • 如果我做我得到这个: 我的PHP版本是: 这是我当前的: 我的symfony版本是: 如何在SF和PHP中安装?

  • 我创建了一个依赖于SLF4J的捆绑包,因此使用Logback来实现OSGI。这一切都捆绑起来并安装正常,但是当我开始捆绑时,我得到以下异常: org.osgi.framework.BundleException: 無法解析 com.felix.test [20](R 20.0): missing requirements [com.felix.test [20](R 20.0)] osgi.wir