首页 > 解决方案 > Servicemix 简单捆绑缺少要求

问题描述

您好,我是 servicemix 的新手,无法启动简单的自编程捆绑包。

我的 pom.xml:

<?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/xsd/maven-4.0.0.xsd">

<!-- Generated by Apache ServiceMix Archetype -->

<modelVersion>4.0.0</modelVersion>

<groupId>de.rupp</groupId>
<artifactId>test</artifactId>
<packaging>bundle</packaging>
<version>1.0-SNAPSHOT</version>
<name>test</name>

<properties>
   <camel.version>3.0.0-M3</camel.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <defaultGoal>install</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4.3</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.6</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Import-Package>*</Import-Package>
                    <Private-Package>de.rupp</Private-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

我的骆驼上下文.xml

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:camel="http://camel.apache.org/schema/spring"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring
  http://camel.apache.org/schema/spring/camel-spring-2.10.3.xsd">
<camelContext id="Merda" xmlns="http://camel.apache.org/schema/spring">
    <packageScan>
         <package>de.rupp</package>
     </packageScan>
 </camelContext>
 </beans>

我只有一门简单的课

public class TestRoute extends RouteBuilder {

@Override
public void configure() throws Exception {
    from("file:in")
        .id("file-in")
        .log("Nachricht: ${body}")
        .to("file:out");

}

}

结果 MANIFEST.MF 是

Manifest-Version: 1.0
Bnd-LastModified: 1560848195732
Build-Jdk: 1.8.0_181
Built-By: bla
Bundle-ManifestVersion: 2
Bundle-Name: test
Bundle-SymbolicName: test
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: de.rupp;uses:="org.apache.camel.builder,org.apache.camel
 .model";version="1.0.0.SNAPSHOT"
Import-Package: org.apache.camel.builder;version="[3.0,4)",org.apache.ca
 mel.model;version="[3.0,4)"
Tool: Bnd-1.50.0

当我将 jar 复制到部署文件夹并使用 bundle:list 时,我看到它已安装 225 | 已安装 | 80 | 1.0.0.快照 | 测试

但是我无法启动它。

karaf@root>开始 225

Error executing command: Error executing command on bundles:
        Error starting bundle 225: Unable to resolve test [225](R 225.14): missi
ng requirement [test [225](R 225.14)] osgi.wiring.package; (&(osgi.wiring.packag
e=org.apache.camel.builder)(version>=3.0.0)(!(version>=4.0.0))) Unresolved requi
rements: [[test [225](R 225.14)] osgi.wiring.package; (&(osgi.wiring.package=org
.apache.camel.builder)(version>=3.0.0)(!(version>=4.0.0)))]

任何帮助将不胜感激。有谁知道编写骆驼包的好教程?

谢谢,

汉斯

标签: apache-camelapache-servicemix

解决方案


您应该使用 ServiceMix 正在使用的 Camel 版本(开箱即用)。ServiceMix 不支持 Camel 3。

此外,我想建议只使用 Apache Karaf 或 Camel 的替代运行时(Spring Boot、Quarkus、Tomcat、Standalone Camel via Camel Main),因为 ServiceMix 不再那么活跃了。


推荐阅读