The problem of generics in springboot return structure

public class Result<T> {

    private int code;

    private String msg;

    private T body;
    

I have a generic type in my return structure definition, and then an error occurs when springboot returns

"No converter found for return value of type: class net.zjump.throwbookserver.bean.Result"

how to solve it!

Mar.12,2021

is not a generic problem, and the error is clear: the converter was not found. There are many common XML and JSON, converters. If you are JSON, check to see if you have added corresponding converters to your POM dependency: jackson-core and jackson-databind.

  1. if there is spring-boot-starter-web , the jackson converter is already included.
  2. whether it is a POJO (get set method or not)
  3. Whether the
  4. annotation is @ RestController

did not write the getset method

Menu