如何在 Maven-bundle-plugin(v2.3.7) 中包含第三方库



我正在使用servicemix(v4.5.3),并希望通过maven-bundle-plugin将我的应用程序(取决于数百个第三方库)部署为捆绑包。

下面是我的绒球.xml

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.7</version>
                <extensions>true</extensions>
                <executions>
                       <execution>
                            <id>wrap-my-dependency</id>
                            <goals>
                                <goal>wrap</goal>
                            </goals>
                            <configuration>
                                 <wrapImportPackage></wrapImportPackage>
                                 <instructions>
                                        <Include-Resource>{maven-resources}</Include-Resource>
                                        <Bundle-ClassPath>.</Bundle-ClassPath>
                                        <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                                        <Embed-Transitive>true</Embed-Transitive> 
                                        <Import-Package>*</Import-Package>
                                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                                        <Bundle-Name>${project.artifactId}</Bundle-Name>
                                        <Bundle-Version>1.0.0</Bundle-Version>
                                        <Bundle-Activator>com.bundle.example.Main</Bundle-Activator>
                                </instructions>
                             </configuration>
                      </execution>
                </executions>
            </plugin>

我已经按照这个来创建捆绑包,但是当我执行 mvn bundle:wrap 时,它会将外部 jar 转换为捆绑包并放入我项目的目标/类文件夹中。

现在,我的问题是我是否必须复制所有捆绑包并将其放入 servicemix 安装目录的部署文件夹中才能运行我的应用程序。我遵循了这种方法,但是在我的应用程序启动时仍然遇到一些错误。

清单文件 :

    Imported Packages
    com.dhtmlx.connector from dhtmlxgridConnector (476)
    com.google.gson,version=[1.7,2) -- Cannot be resolved
    com.googlecode.ehcache.annotations,version=[1.1,2) -- Cannot be resolved
    com.hazelcast.core,version=[2.6,3) from com.hazelcast (437)
    com.tinkerpop.blueprints -- Cannot be resolved
    com.tinkerpop.blueprints.impls.orient -- Cannot be resolved
    com.tinkerpop.frames -- Cannot be resolved

这只是我的捆绑包清单文件的一小部分。在这里,一些捆绑包仍未解决,我认为启动捆绑包的问题。

第二个查询:在使用 maven-bundle-plugin 时,是否有更好的方法来处理所有第三方库。等待一些有价值的建议。

当我需要在 Servicemix 中将 JAR 转换为捆绑包并导入时,我使用:

./bin/servicemix

osgi:install -s wrap:file:////"jar_location Ex: /lib/ojdbc6-13.jar"

执行关机命令,选择是选项。

现在,您的 JAR 将在 ServiceMix 中作为捆绑包提供。

最新更新