AWS SQS: java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge?
AWS SQS: java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge?
我正尝试在我的 Java 代码中向 SQS 发送消息,如下所示:
public void pushToSQS(){
String queueURL = "https://sqs.us-east-1.amazonaws.com/205135634997/myQueue.fifo";
try {
final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
sqs.sendMessage(new SendMessageRequest(queueURL,
"test message"));
} catch (final AmazonServiceException e) {
log.error("Error: " + e.getMessage());
}
}
然而在行:final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
我收到错误:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonMerge
我已将以下内容添加到我的 pom.xml:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-models</artifactId>
<version>1.11.86</version>
</dependency>
下面是项目中所有的jackson
依赖:
在 mvn
依赖树中我可以看到:
+- org.jboss.resteasy:resteasy-multipart-provider:jar:3.0.19.Final:provided
[INFO] | +- org.jboss.resteasy:resteasy-client:jar:3.0.19.Final:provided
[INFO] | +- org.jboss.resteasy:resteasy-jaxb-provider:jar:2.3.5.Final:provided
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:2.2.5.jboss-1:provided
[INFO] | | +- com.sun.istack:istack-commons-runtime:jar:2.6.1:provided
[INFO] | | \- com.sun.xml.txw2:txw2:jar:20110809:provided
[INFO] | +- com.sun.mail:javax.mail:jar:1.5.5:provided
[INFO] | \- org.apache.james:apache-mime4j:jar:0.6:provided
[INFO] \- org.jboss.resteasy:resteasy-jackson2-provider:jar:3.0.19.Final:provided
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
导致此错误的原因是什么?
看起来你有两次杰克逊。考虑一下:
+- org.jboss.resteasy:resteasy-multipart-provider:jar:3.0.19.Final:provided
[INFO] \- org.jboss.resteasy:resteasy-jackson2-provider:jar:3.0.19.Final:provided
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:provided
还有这个:
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
请将顶级依赖项删除到 com.fasterxml.jackson.core:jackson-databind:jar:2.9.6
并查看它是否有效。
根据错误,代码正在尝试加载 'com/fasterxml/jackson/annotation/JsonMerge' 'jackson-annotations:jar:2.6.3' 中不可用.根据上面共享的 Maven 依赖项,正在引用 Jackson 库的 2.6.3 版。
但是 要求 class 存在于版本 2.9.6 中。所以建议使用2.9.6。建议在 2.9.6 版本中也使用 jackson-databind 和 jackson-core。
我看到 jackson-databind 和 jackson-annotations 有两个版本。
在 2.9.2+ 版本中,JsonMerge 在 jackson-annotations 中可用。
使用 mvn dependency:tree 使用 Maven 依赖树查找并排除旧版本的 jackson-annotations 和 jackson:databind
我正尝试在我的 Java 代码中向 SQS 发送消息,如下所示:
public void pushToSQS(){
String queueURL = "https://sqs.us-east-1.amazonaws.com/205135634997/myQueue.fifo";
try {
final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
sqs.sendMessage(new SendMessageRequest(queueURL,
"test message"));
} catch (final AmazonServiceException e) {
log.error("Error: " + e.getMessage());
}
}
然而在行:final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
我收到错误:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonMerge
我已将以下内容添加到我的 pom.xml:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-models</artifactId>
<version>1.11.86</version>
</dependency>
下面是项目中所有的jackson
依赖:
在 mvn
依赖树中我可以看到:
+- org.jboss.resteasy:resteasy-multipart-provider:jar:3.0.19.Final:provided
[INFO] | +- org.jboss.resteasy:resteasy-client:jar:3.0.19.Final:provided
[INFO] | +- org.jboss.resteasy:resteasy-jaxb-provider:jar:2.3.5.Final:provided
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:2.2.5.jboss-1:provided
[INFO] | | +- com.sun.istack:istack-commons-runtime:jar:2.6.1:provided
[INFO] | | \- com.sun.xml.txw2:txw2:jar:20110809:provided
[INFO] | +- com.sun.mail:javax.mail:jar:1.5.5:provided
[INFO] | \- org.apache.james:apache-mime4j:jar:0.6:provided
[INFO] \- org.jboss.resteasy:resteasy-jackson2-provider:jar:3.0.19.Final:provided
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
导致此错误的原因是什么?
看起来你有两次杰克逊。考虑一下:
+- org.jboss.resteasy:resteasy-multipart-provider:jar:3.0.19.Final:provided
[INFO] \- org.jboss.resteasy:resteasy-jackson2-provider:jar:3.0.19.Final:provided
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.6.3:provided
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.6.3:provided
[INFO] \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:provided
还有这个:
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
请将顶级依赖项删除到 com.fasterxml.jackson.core:jackson-databind:jar:2.9.6
并查看它是否有效。
根据错误,代码正在尝试加载 'com/fasterxml/jackson/annotation/JsonMerge' 'jackson-annotations:jar:2.6.3' 中不可用.根据上面共享的 Maven 依赖项,正在引用 Jackson 库的 2.6.3 版。
但是 要求 class 存在于版本 2.9.6 中。所以建议使用2.9.6。建议在 2.9.6 版本中也使用 jackson-databind 和 jackson-core。
我看到 jackson-databind 和 jackson-annotations 有两个版本。 在 2.9.2+ 版本中,JsonMerge 在 jackson-annotations 中可用。
使用 mvn dependency:tree 使用 Maven 依赖树查找并排除旧版本的 jackson-annotations 和 jackson:databind