我对杰克逊和斯普林都是新手,所以如果这是一个愚蠢的问题,请原谅。我一直在研究一个处理 JSON 请求的简单 spring 项目。我有 GET 和 DELETE 工作,但是当我尝试 POST 时出现错误:
SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/CynergyRestStarterKit] threw exception [Handler processing failed; ...with root cause
java.lang.NoSuchMethodError: org.codehaus.jackson.map.type.TypeFactory.type(Ljava/lang/reflect/Type;Lorg/codehaus/jackson/type/JavaType;)Lorg/codehaus/jackson/type/JavaType;
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType(MappingJacksonHttpMessageConverter.java:229)
这是我的 Java 服务:
@RequestMapping(value = "/todos", method = RequestMethod.GET)
public @ResponseBody
List<TodoItem> getTodos() {
return tasks;
}
@RequestMapping(value = "/todo/create", method = RequestMethod.POST)
public @ResponseBody
TodoItem createTodo(@RequestBody TodoItem item) {
return null;
}
我究竟做错了什么?