我有一个小型的Quarkus应用程序用例,该应用程序必须能够调用REST终结点,但不应运行Web服务器本身。
具有以下依赖项,不支持JSON反序列化:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson</artifactId>
</dependency>
运行应用程序将输出以下日志:
WARN [io.qua.res.com.dep.ResteasyCommonProcessor] (build-11) Quarkus detected the need of REST JSON support but you have not provided the necessary JSON extension for this. You can visit https://quarkus.io/guides/rest-json for more information on how to set one.
...
ERROR [...] ProcessingException while creating reply for journey details request: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class X.
(基于该票证添加了警告:https://github.com/quarkusio/quarkus/issues/4157)
将配置更改为:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
REST客户端Jackson的反序列化工作,但它也启动了Web服务器。
是否可以在不运行RESTEasy Web服务器的情况下在REST客户端上支持Jackson反序列化?
选项1:我可以为此添加特定的依赖项吗?我分别处理了quarkus-resteasy-jackson的依赖项,但没有使其起作用。
选项2:quarkus-jackson依赖项中缺少某些内容吗?我认为应该能够支持REST客户端上的Jackson序列化,而无需包含完整的RESTEasy依赖项?
其他选项?对于不使用的功能,向约20MB的应用程序添加约10MB的RSS内存是很多开销的明智之举:)
您还缺少另外一个依赖项,即resteasy-jackson2-provider
这是应该起作用的库的组合:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
</dependency>
此选项下面的注释中指定的[PS为Ken的PS不适用于本机图像