【问题标题】:Issue with adding jar in OSGI bundle using <Embed-Dependency>使用 <Embed-Dependency> 在 OSGI 包中添加 jar 的问题
【发布时间】:2011-09-10 12:16:59
【问题描述】:

我正在尝试在 OSGI 包中嵌入第三方库和应用程序 jar。我阅读了 felix maven 插件文档并尝试使用 Embed-Dependency。但它似乎没有任何效果。这是我的pom


<dependencies>
        &ltdependency>
            &ltgroupId>com.test</groupId>
            <artifactId>taxonomymessagebundle</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.0.1</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>com.test.taxonomy.dao.*;version=1.0.0</Export-Package>
                        <Import-Package>*</Import-Package>
                    </instructions>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
                </configuration>
            </plugin>
        </plugins>
    </build>

我是 mvn clean install 来构建捆绑包。安装后,我查看了清单文件,它没有显示任何 Bundle-Classpath 或 Embed 信息。看起来它完全忽略了指令。此外,捆绑包中也没有嵌入两个依赖的 jar。

这是生成的清单:

代码>
清单版本:1.0
导出包:com.test.taxonomy.dao;uses:="com.autodesk.taxonomy";version="1.0.0"
捆绑版本:1.0.0
构建-Jdk:1.6.0_21
建造者:bandops
工具:Bnd-0.0.357
Bnd-LastModified: 1307492329392
Bundle-Name: Taxonomy Dao Bundle
捆绑清单版本:2
创建者:Apache Maven Bundle Plugin
导入包:com.test.taxonomy.dao;version="1.0",com.autodesk.test.message
Bundle-SymbolicName:com.test.taxonomy.daobundle

任何指针将不胜感激。

-谢谢

【问题讨论】:

    标签: maven osgi esb


    【解决方案1】:

    &lt;Embed-Dependency&gt;&lt;Embed-Transitive&gt; 都应该在 &lt;instructions&gt; 标记内。

    【讨论】:

    • .我的错,感谢您指出这一点。只是跟进,一旦我运行 mvn install,我收到一个异常,说我必须在 中为所有依赖包提供一个条目。这是由于属性 true ?处理这类场景的最佳做法是什么?
    • &lt;Import-Package&gt;*&lt;/Import-Package&gt; 不是必需的,这可能会导致您看到该消息。一般来说,我会小心使用&lt;Embed-Transitive&gt; 将所有东西和厨房水槽嵌入你的包中。 stackoverflow 上可能还有另一个问题,对此场景有建议。
    猜你喜欢
    • 1970-01-01
    • 2016-08-20
    • 2012-10-30
    • 2011-09-21
    • 1970-01-01
    • 2018-09-22
    • 2020-03-29
    • 2017-06-05
    • 2023-03-23
    相关资源
    最近更新 更多