gpt4 book ai didi

java - Jersey 2.9 和 Jackson 提供商

转载 作者:太空宇宙 更新时间:2023-11-04 06:44:33 25 4
gpt4 key购买 nike

我正在使用 Jersey 2.9 和 Jackson,在这里您可以找到依赖项:

 <dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-client</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>

当我执行此客户端代码时,我有一些 POJO 类,例如 Student.class,其中包含一些属性:

Student studentRequest = new Student(); 

Response response = target()
.path("/students/register")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.json(studentRequest), Response.class);

代码不起作用,我得到了这个异常:

javax.ws.rs.ProcessingException: com.fasterxml.jackson.jaxrs.base.ProviderBase._configForWriting(Lcom/fasterxml/jackson/databind/ObjectWriter;[Ljava/lang/annotation/Annotation;)Lcom/fasterxml/jackson/jaxrs/cfg/EndpointConfigBase;
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:233)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655)
...
at
Caused by: java.lang.AbstractMethodError: com.fasterxml.jackson.jaxrs.base.ProviderBase._configForWriting(Lcom/fasterxml/jackson/databind/ObjectWriter;[Ljava/lang/annotation/Annotation;)Lcom/fasterxml/jackson/jaxrs/cfg/EndpointConfigBase;
at com.fasterxml.jackson.jaxrs.base.ProviderBase._configForWriting(ProviderBase.java:469)
...

有人知道我为什么得到这个堆栈跟踪吗?

谢谢!

最佳答案

遇到同样的问题,在我的例子中,它通过将 maven 依赖管理系统的实现作为依赖项添加到 pom.xml 中的客户端来帮助修复 java.lang.AbstractMethodError:

    <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.2</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.2</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.2</version>
</dependency>

关于java - Jersey 2.9 和 Jackson 提供商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24187028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com