最新のCamelとREST DSLルートの問題に直面しています。完全なコードはここから見つけることができます:https://github.com/mikevoxcap/nvisia-catalog-camel-service。私の質問は、どのジャクソンのバージョン私は、もはやこの例外を受け取るに標的にされなければならないですCamelとJacksonの依存関係に関する問題
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType()Lcom/fasterxml/jackson/databind/JavaType;
....
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:926)
at org.apache.camel.component.jackson.JacksonDataFormat.marshal(JacksonDataFormat.java:154)
at org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:69)
:私はルートを実行しようとすると、私は、以下の根本的な原因を例外を取得しています。
私は、次の依存関係を持ち込むことだ:それはバージョンの競合に来るとき
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring.boot.version>1.3.5.RELEASE</spring.boot.version>
<camel.version>2.17.1</camel.version>
<java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-servlet</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java</artifactId>
<version>${camel.version}</version>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<version>${camel.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
私が受け取った例外にいくつかの検索を行った後、いくつかの人々がこの問題に遭遇してきました。私は、camel-jacksonライブラリがjackson-module-jaxb-annotations 2.7.2を持ってきていることに気付きましたが、残りのjacksonライブラリは2.6.6です。私はjackson-module-jaxb-annotations 2.7.2を除外して、次に2.6.6を直接取り込みましたが、それでも例外が発生しました。
私のルートは比較的簡単です:
// Definition of the get catalog item endpoint
rest("/catalogItem").
// This is a GET method call for getting a catalog item by ID.
get("{id}").
// Description of what this method does
description("Retrieve a catalog item by ID").
// Define the output type that will be returned from this method
outType(CatalogItem.class)
// Define where the message is routed to as a URI. Here we use a
// Spring Bean and define the bean method to invoke. Note that Camel
// has converted the ID placeholder from the URL into a header
// entry.
.to("bean:catalogService?method=getCatalogItem(${header.id})");
JSONの種類も非常に単純であると私のオブジェクトが使用されている:
public class CatalogItem {
private int id;
private double price;
private String catalogItemType;
private List<CatalogItemAttribute> attributes;
public class CatalogItemAttribute {
private String attributeName;
private String attributeValue;
によって引き起こされるこのエラーは ':java.lang.NoSuchMethodError'が間違ったメソッド名を使用しているか、あなたは、もはやこのメソッドは実装されていないか、まだ使用しているあなたの依存関係のバージョンを使用しているいずれかのことを示していますそれが実装されていないライブラリバージョン。 –
@JorgeCamposはい、それは私の質問がここにあります。 POMが解決されると、Jackson注釈の依存関係がより高いバージョンになります。私は、ジャクソンのコアライブラリを除外し、2.6.6以下のバージョンへのダウングレードが必要な場合、バージョンを2.7.2に増やすべきかどうかを判断しようとしています。 –
私は、spring-boot-starter-web、spring-boot-starter-actuator、camel-jackson、camel-swagger-javaの依存関係にjackson-annotations、jackson-core、およびjackson-databindの除外項目を追加しました。次に、これら3つのライブラリの依存関係を2.7.2で明確に定義し、コードが動作するようになりました。いくつかの調査の後、これはCamelよりBootほど問題があるように見えます。 Jacksonの2.7へのBootアップデートの1.4のように見えるので、私はこれを今答えとして与える必要があります。 –