【问题标题】:how to include third parties library in maven-bundle-plugin(v2.3.7)如何在 maven-bundle-plugin(v2.3.7) 中包含第三方库
【发布时间】:2019-05-15 21:45:23
【问题描述】:

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

下面是我的 pom.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>

我遵循this 创建包,但是当我执行 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 时是否有更好的方法来处理所有 3rd 方库。 等待一些有价值的建议。

【问题讨论】:

    标签: deployment dependency-management osgi-bundle apache-servicemix maven-bundle-plugin


    【解决方案1】:

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

    ./bin/servicemix

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

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

    现在您的 JAR 将在 ServiceMix 中以捆绑包的形式提供。

    【讨论】:

      猜你喜欢
      • 2013-10-11
      • 1970-01-01
      • 2017-04-17
      • 2012-09-08
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多