我花了几天时间试图了解如何部署为 OSGI 包并需要一些帮助。我正在使用 servicemix 4.5.2、maven 3.1.0 和 maven-bundle-plugin 2.4.0。我在我的 .pom 中添加了以下标签
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
我的包构建,当我部署到 servicemix 中时,我得到了一系列 BundleExceptions。我迭代地将丢失的包添加到我的 pom 中,直到我碰壁。“缺少需求包;(package=com.ibm.ejs.ras)”。直接的问题是我找不到要下载的 ras.jar 或在 Maven 存储库中。但我认为更大的问题是我做错了一些事情,导致我不得不手动追踪传递依赖。
我已经挖掘并看到使用 Spring 和 Fuse 的预捆绑版本解决了常见问题。Fuse 存储库似乎已经消失,而 Spring 存储库似乎正在日落,并且没有我需要的所有 .jar。我还尝试了我在另一篇文章中看到的 bundleall maven-bundle-plugin,目标现在已被弃用)。这导致“为项目 org.beanshell:bsh-core 生成 OSGi 包时出错:aQute.bnd.osgi.Descriptors$PackageRef 无法转换为 java.lang.String”。
我使用过以前(OSGI 之前)版本的 servicemix 和 camel,并且对这两种产品都非常重视。然而,为了克服 OSGI 障碍,我正在失去动力(和工作时间),而 Mule 变得越来越有吸引力。如果有人有一些见解,他们将不胜感激。
谢谢。
我的pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.abc</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>myartifact</artifactId>
<packaging>bundle</packaging>
<name>myartifact</name>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mail</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.35.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Export-Package>com.mycompany.abc.myartifact</Export-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>