使用Jackson JSON库与骆驼的例外

前端之家收集整理的这篇文章主要介绍了使用Jackson JSON库与骆驼的例外前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在使用带有骆驼的Jackson JSON库时遇到了麻烦.
例外是:
FailedToCreateRouteException: Failed to create route... because of Data format 'json-jackson' could not be created. Ensure the data format is valid and the associated Camel component is present on the classpath

这是类路径通知的开始,杰克逊的libs在那里:

<<< camel-maven-plugin:2.9.0:run (default-cli) @ portlistener <<<

--- camel-maven-plugin:2.9.0:run (default-cli) @ portlistener ---
Classpath = [file:/C:/Users/andrew.b-ext/Workspace/portlistener/target/classes/,file:/C:/Users/andrew.b-ext/.m2/repository/org/codehaus/jackson/jackson-asl/1.9.13/jackson-core-asl-1.9.13.jar,file:/C:/Users/andrew.b-ext/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar,file:/C:/Users/andrew.b-ext/.m2/repository/org/codehaus/jackson/jackson-jaxrs/1.9.13/jackson-jaxrs-1.9.13.jar,...snip...

我的pom有杰克逊:

<properties>
    <camel.version>2.12.2</camel.version>
    <cxf.version>2.7.8</cxf.version>
    <activemq.version>5.6.0</activemq.version>
</properties>

<dependencies>
  <dependency>
     <groupId>org.codehaus.jackson</groupId>
     <artifactId>jackson-core-asl</artifactId>
     <version>1.9.13</version>
  </dependency>
  <dependency>
     <groupId>org.codehaus.jackson</groupId>
     <artifactId>jackson-mapper-asl</artifactId>
     <version>1.9.13</version>
  </dependency>
  <dependency>
     <groupId>org.codehaus.jackson</groupId>
     <artifactId>jackson-jaxrs</artifactId>
     <version>1.9.13</version>
  </dependency>

这是我对Dataformat对象的定义:

<bean id="jsonDataformat" class="org.apache.camel.model.dataformat.JsonDataFormat">
    <property name="unmarshalType" value="java.util.Map" />
    <property name="library" value="Jackson"></property>
</bean>

我尝试将jsonDataformat声明更改为:

<camel:dataFormats>
            <camel:json id="jsonDataformat" library="Jackson"/>
</camel:dataFormats>

当我这样做时,我得到一个不同的错误

Configuration problem: Cannot locate BeanDefinitionParser for element [dataFormats]

谁能看到我做错了什么?

谢谢,

安德鲁
整个pom.xml

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/maven-v4_0_0.xsd\”\u0026gt;

<modelVersion>4.0.0</modelVersion>

<!--<parent> <artifactId>core</artifactId> <groupId>com.xxxx.clinical</groupId> 
    <version>3.3.3.3.1</version> </parent> -->
<groupId>com.xxxx.clinical</groupId>
<artifactId>portlistener</artifactId>
<packaging>jar</packaging>
<name>portlistener</name>
<version>0.0.0.0.01</version>

<properties>
    <camel.version>2.12.2</camel.version>
    <cxf.version>2.7.8</cxf.version>
    <activemq.version>5.6.0</activemq.version>
    <jackson.version>1.9.13</jackson.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-jaxrs</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <!-- This dependency is needed if you're using the Jetty container -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>${activemq.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-camel</artifactId>
        <version>${activemq.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-pool</artifactId>
        <version>${activemq.version}</version>
    </dependency>
    <!-- Camel -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xbean</groupId>
        <artifactId>xbean-spring</artifactId>
        <version>3.15</version>
    </dependency> 
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jms</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-hl7</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-netty</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-cxf</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <!-- hapi -->
    <dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-base</artifactId>
        <version>2.1</version>
        <exclusions>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v25</artifactId>
        <version>2.1</version>
    </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>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>
</dependencies>

<build>
    <defaultGoal>install</defaultGoal>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <!-- allows the route to be ran via 'mvn camel:run' -->
        <plugin>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-maven-plugin</artifactId>
            <version>2.9.0</version>
        </plugin>
    </plugins>
</build>
</project>

解决方法

你错过了camel-jackson依赖:
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jackson</artifactId>
    <version>${camel-version}</version>
</dependency>

这会引入jackson-core-asl和jackson-mapper-asl,但不幸的是杰克森 – 贾克斯.对于后者,您仍然需要在兼容版本中显式依赖.

原文链接:https://www.f2er.com/js/159410.html

猜你在找的JavaScript相关文章