4

我正在使用 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>

我已经按照这个来创建包,但是当我执行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 方库。等待一些有价值的建议。

4

1 回答 1

0

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

./bin/servicemix

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

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

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

于 2019-05-15T13:45:23.500 回答