我正在使用 servicemix(v4.5.3) 并希望通过 maven-bundle-plugin 将我的应用程序(依赖于数百个第三方库)部署为 bundle 。
下面是我的 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用于创建 bundle ,但是当我执行 mvn bundle:wrap 时,它将外部 jar 转换为 bundle 并放入我的项目的 target/classes 文件夹中。
现在,我的问题是我是否必须复制所有包并将其放入 servicemix 安装目录的部署文件夹中才能运行我的应用程序。我已经遵循了这种方法,但在应用程序启动时仍然遇到一些错误。
list 文件:
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
这只是我的捆绑 list 文件的一小部分。这里有些 bundle 仍未解决,我认为是启动我的 bundle 的问题。
第二个查询:在使用 maven-bundle-plugin 时是否有更好的方法来处理所有第三方库。 等待一些宝贵的建议。
最佳答案
当我需要将 JAR 转换为 Servicemix 中的 bundle 并导入时,我使用:
./bin/servicemix
osgi:install -s wrap:file:////"jar_location Ex:/lib/ojdbc6-13.jar"
执行关机命令,选择yes选项。
现在您的 JAR 将在 ServiceMix 中作为 bundle 提供。
关于deployment - 如何在 maven-bundle-plugin(v2.3.7) 中包含第三方库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21017725/