报错】nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException"/>
【springboot报错】nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException
java springboot开发api时的报错,没复制全,懒得重现
nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class
问题是在于return的这个class里面没有针对responseBody做处理,意思是要告诉responseBody里对应的那些key在somReturnClass这个类里对应的key是啥(虽然名字一样,但代码不会自动帮你对应上)
@GetMapping("/test")public List<someReturnClass> getResult(){return .....;}
解决方法:
- 在someReturnClass加上@Getter和@Setter
@Getter
@Setter
@Builder
public class someReturnClass {private String db;private String table;// ...
}
或者:
2. 在someReturnClass的每个变量名上加上@JsonProperty(“xxx”) ,每个都要加,比较麻烦
@Builder
public class someReturnClass {@JsonProperty("db")private String db;@JsonProperty("table")private String table;// ...
}
更多推荐
【springboot报错】nested exception is com.fasterxml.jackson.databind.exc.InvalidDefi
发布评论