osgi - 在Pom文件中将jar添加到apache felix?

标签 osgi apache-felix

如何将 jar 添加到 Apache Felix 中的包中?

我正在使用 maven,通过 maven-bundle-plugin 来管理 OBR 中的包。

但是我不确定在哪里声明 POM 中对 jar 的依赖关系,以便 maven 正确地将其编译到最终的包中。

这是我的插件在 pom 中的样子:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
    <instructions>
        <Bundle-Category>sample</Bundle-Category>
        <Bundle-SymbolicName>${artifactId}
                 </Bundle-SymbolicName>
        <Export-Package>
            //blahblah
        </Export-Package>
    </instructions>

    <!-- OBR -->
    <remoteOBR>repo-rel</remoteOBR>
    <prefixUrl>file:///C:/Users/blah/Projects/Eclipse3.6-RCP-64/Felix/obr-repo/releases</prefixUrl>
    <ignoreLock>true</ignoreLock>
</configuration>

最佳答案

如果你有这样的依赖

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.14</version>
</dependency>

您可以使用

将其嵌入到您的包中
<instructions>
    <!-- embedded dependencies -->
    <Embed-Dependency>log4j;groupId=log4j;inline=false</Embed-Dependency>
</instructions>

您可以在 Bundle Plugin for Maven 的“嵌入依赖项”部分找到详细说明。网站

关于osgi - 在Pom文件中将jar添加到apache felix?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4875648/

相关文章:

java - 有没有办法访问包的类代码中 @Component 声明的服务属性?

java - 在 glassfish 3.1.2.2 上部署 jersey/helloworld-osgi-webapp 时出错

OSGI 容器中的 Scala?

java - 创建需要用户参数的 OSGI 服务

java - 当我使用 osgi 包重新启动服务器时 Glassfish 崩溃

service - 为什么我应该更喜欢 OSGi 服务而不是导出的包?

java - OSGi 菲利克斯 : Sharing a class between the host application and a bundle possible?

java - Apache Felix 上的 OSGi 部署

java - 对于 OSGi 运行时可用的类型 ( io.netty.common ),出现 ClassNotFoundException

osgi - 使用同一文件安装两个 bundle