我如何使用 Quarkus 中的 Jackson return JAX-RS 中的对象作为 YAML?
How do I return an object in JAX-RS as YAML using Jackson in Quarkus?
我使用 https://code.quarkus.io(带有 RESTEasy Jackson 扩展)创建了一个 Quarkus 项目,一个 Greeting class 定义为:
public class Greeting {
private final String message;
public Greeting(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
还有一个 JAX-RS 端点 return 它作为 YAML,所以我写了以下代码:
@Path("/greeting")
public class GreetingResource {
@GET
@Produces("application/yaml")
public Greeting hello() {
return new Greeting("hello");
}
}
我还在我的 Quarkus 项目中添加了以下依赖项到 return YAML:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-yaml-provider</artifactId>
</dependency>
然而,当我到达终点时,显示以下错误:
2020-05-22 10:55:55,693 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002010: Failed to execute: javax.ws.rs.NotSupportedException: RESTEASY003200: Could not find message body reader for type: class org.acme.sample.Greeting of content type: application/yaml; charset=ISO-8859-1
建议的解决方法是什么?
除了在 pom.xml 中添加依赖项外,请务必将以下内容添加到 application.properties
中:
quarkus.index-dependency.yaml.group-id=com.fasterxml.jackson.jaxrs
quarkus.index-dependency.yaml.artifact-id=jackson-jaxrs-yaml-provider
我使用 https://code.quarkus.io(带有 RESTEasy Jackson 扩展)创建了一个 Quarkus 项目,一个 Greeting class 定义为:
public class Greeting {
private final String message;
public Greeting(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
还有一个 JAX-RS 端点 return 它作为 YAML,所以我写了以下代码:
@Path("/greeting")
public class GreetingResource {
@GET
@Produces("application/yaml")
public Greeting hello() {
return new Greeting("hello");
}
}
我还在我的 Quarkus 项目中添加了以下依赖项到 return YAML:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-yaml-provider</artifactId>
</dependency>
然而,当我到达终点时,显示以下错误:
2020-05-22 10:55:55,693 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002010: Failed to execute: javax.ws.rs.NotSupportedException: RESTEASY003200: Could not find message body reader for type: class org.acme.sample.Greeting of content type: application/yaml; charset=ISO-8859-1
建议的解决方法是什么?
除了在 pom.xml 中添加依赖项外,请务必将以下内容添加到 application.properties
中:
quarkus.index-dependency.yaml.group-id=com.fasterxml.jackson.jaxrs
quarkus.index-dependency.yaml.artifact-id=jackson-jaxrs-yaml-provider