Camel:Camel组件的未解决依赖项异常

时间:2019-05-11 22:28:43

标签: java maven apache-camel

我正在创建一个基于Maven的Camel组件。我在POM.xml中添加了相关的依赖项,但仍然出现以下异常:

未解决的依赖项:(&(component = FileFormatConversion)(objectClass = org.apache.camel.spi.ComponentResolver))

我能够构建并运行Maven项目。但是,我的组件jar位于组件文件夹中:

Component Folder

任何人都可以告知我的POM是否存在问题或此异常的原因。这是我的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>
<groupId>FileFormatConversion</groupId>
<artifactId>FileFormatConversion</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<name>${project.groupId}.${project.artifactId}</name>

<properties>
    <camel.version>2.18.0</camel.version>
    <import.packages>*;version="0";resolution:=optional</import.packages>
    <private.packages>!*</private.packages>
    <symbolic.name>${project.groupId}</symbolic.name>
    <embed-dep>*;scope=compile;type=!pom;inline=true</embed-dep>
    <unpack-bundle>false</unpack-bundle>
    <maven.test.skip>true</maven.test.skip>
    <maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>

<dependencies>
    <!-- Check for the latest version of this artifact in central maven repository -->
    <dependency>
        <groupId>com.sap.cloud.adk</groupId>
        <artifactId>com.sap.cloud.adk.build.archive</artifactId>
        <version>1.24.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-component -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-component</artifactId>
        <version>1.4.0</version>
    </dependency>



    <!-- https://mvnrepository.com/artifact/in.jlibs/jlibs-xsd -->
    <dependency>
        <groupId>in.jlibs</groupId>
        <artifactId>jlibs-xsd</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>in.jlibs</groupId>
        <artifactId>jlibs-xml</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>in.jlibs</groupId>
        <artifactId>jlibs-visitor</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>in.jlibs</groupId>
        <artifactId>jlibs-core</artifactId>
        <version>2.2.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache/xerces -->
    <dependency>
        <groupId>org.apache</groupId>
        <artifactId>xerces</artifactId>
        <version>2.9.0</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>
    </dependency>
    <!-- testing -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test</artifactId>
        <version>${camel.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <defaultGoal>install</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <version>4.2.0</version>
            <inherited>true</inherited>

            <configuration>
                <excludeDependencies>true</excludeDependencies>

                <instructions>
                    <Include-Resource>src/main/resources/,lib/</Include-Resource>
                    <Bundle-SymbolicName>${symbolic.name}</Bundle-SymbolicName>
                    <Bundle-Classpath>.,jax-qname.jar,jaxmexs-0.5.jar,xsd-2.2.3.jar,jlibs-core-2.2.1.jar,jlibs-visitor-2.2.1.jar,jlibs-xml-2.2.1.jar,
                        jlibs-xsd-2.2.1.jar,xercesImpl-2.11.0.jar,xml-apis-1.4.01.jar,FileFormatConversion-1.0.0.jar
                    </Bundle-Classpath>

                    <Import-Package>${import.packages}</Import-Package>

                </instructions>
            </configuration>

        </plugin>




        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/libs</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <excludeTransitive>true</excludeTransitive>

                        <!-- Specify the artifacts to be excluded in the dependencies -->
                        <excludeArtifactIds></excludeArtifactIds>

                        <!-- Specify the group ids to be excluded in the dependencies -->
                        <excludeGroupIds>com.sap.cloud.adk,org.apache.camel,org.slf4j,log4j,in.jlibs,xerces,org.apache</excludeGroupIds>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.sap.cloud.adk</groupId>
            <artifactId>com.sap.cloud.adk.build.archive</artifactId>
            <version>1.24.0</version>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.sap.cloud.adk</groupId>
                <artifactId>com.sap.cloud.adk.build.archive</artifactId>
                <executions>
                    <execution>
                        <id>build-adapter</id>
                        <phase>install</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <adapterProjectDirectory>${project.basedir}</adapterProjectDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

2 个答案:

答案 0 :(得分:0)

这是什么?

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-component</artifactId>
        <version>1.4.0</version>
    </dependency>

这看起来不正确,因为它来自Camel1.x。您应该删除它。

您需要进一步说明如何运行此程序?好像您使用OSGi / Karaf之类的东西。但是,请看一下如何以任何现有组件为例来构建自定义组件,或者以Camel Maven原型为基础。

答案 1 :(得分:0)

我自己解决了这个问题。问题在下面的语句中:

$ {import.packages}