简体   繁体   English

没有找到 class org.jooq.JSON 的序列化程序,也没有发现创建 BeanSerializer 的属性

[英]No serializer found for class org.jooq.JSON and no properties discovered to create BeanSerializer

by implementing a method as a service for API, i faced this problem通过为 API 实现一种方法即服务,我遇到了这个问题

No serializer found for class org.jooq.JSON and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]-> db.jooq.tables.pojos.Query["queryJson"])没有找到 class org.jooq.JSON 的序列化程序,也没有发现创建 BeanSerializer 的属性(为避免异常,禁用 SerializationFeature.FAIL_ON_EMPTY_BEANS)(通过参考链:java.util.ArrayList[0]-> db.jooq.tables.pojos。查询["queryJson"])

The Jooq POJO of my Query (TABLE) is:我的查询(表)的 Jooq POJO 是:

 private Integer id; 
 private JSON    queryJson;

and the method which give a list of query as a respond is给出查询列表作为响应的方法是

 @Produces(MediaType.APPLICATION_JSON)   public Response
 getQueries(@PathParam("ownerId") String ownerId,
       @PathParam("roomId") String hotelroom) throws JsonProcessingException {
     List<Query> queries = DatabaseUtil.getQueries(dsl, UUID.fromString(hotelroom));
     return Response.ok(queries).build();}

But there is no serialize and if I change the jooq POJO to this:但是没有序列化,如果我将 jooq POJO 更改为:

private Integer id; 
private String queryJson;

Then the output of my response will have no error by serializing.那么我的响应的output序列化就没有错误了。 Does any one have an idea, how to solve this problem in jooq有没有人知道如何在 jooq 中解决这个问题

Assuming you're using Jackson, you can annotate your JSON property with JsonRawValue :假设您使用的是 Jackson,您可以使用JsonRawValue注释您的JSON属性:

private Integer id; 
@JsonRawValue
private JSON    queryJson;

If you need to also read the value from JSON, you can do this:如果您还需要读取 JSON 中的值,您可以这样做:

private Integer id; 
@JsonRawValue
@JsonDeserialize(using = JSONDeserializer.class)
private JSON    queryJson;

... with: ... 和:

class JSONDeserializer extends JsonDeserializer<JSON> {

    @Override
    public JSON deserialize(JsonParser p, DeserializationContext ctxt)
    throws IOException {
        Object t = p.readValueAsTree();
        return t == null ? null : JSON.json("" + t);
    }
}

A future jOOQ version (not yet 3.16), might offer native support in the code generator for such annotations: https://github.com/jOOQ/jOOQ/issues/13333未来的 jOOQ 版本(还不是 3.16)可能会在代码生成器中为此类注释提供本机支持: https://github.com/jOOQ/jOOQ/issues/13333

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法编写 JSON:未找到类 org.json.JSONObject 的序列化程序,也未发现用于创建 BeanSerializer 的属性 - Could not write JSON: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer i / o问题没有为类org.json.JSONObject找到序列化程序,也没有发现创建BeanSerializer的属性 - Issue with i/o No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer 收到此错误 No serializer found for class org.json.JSONObject 并且没有发现用于创建 BeanSerializer 的属性 - Getting this error No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer 错误:没有找到 class org.json.JSONObject 的序列化程序,也没有发现创建 BeanSerializer 的属性 - Error: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer 找不到针对类org.json.JSONObject的序列化程序,也未找到创建BeanSerializer的属性 - No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer Jackson:没有找到 class ~~~~~ 的序列化器,也没有发现创建 BeanSerializer 的属性 - Jackson: No serializer found for class ~~~~~ and no properties discovered to create BeanSerializer 没有找到 class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor 的序列化程序,也没有发现创建 BeanSerializer 的属性 - No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer 无法编写 JSON:未找到类 java.io.FileDescriptor 的序列化程序,也未发现用于创建 BeanSerializer 的属性 - Could not write JSON: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer 没有找到 class 的序列化器,没有发现创建 BeanSerializer 的属性(为避免异常,禁用 SerializationFeature.FAIL_ON_EMPTY_BEANS) - No serializer found for class,no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) 没有为类java.util.logging.ErrorManager找到序列化程序,也没有发现创建BeanSerializer的属性 - No serializer found for class java.util.logging.ErrorManager and no properties discovered to create BeanSerializer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM