我正在尝试在我的项目中使用spring数据,我更喜欢使用xml配置而不是使用spring boot,这就是我正在做的事情:
: 春天:4.1.4.RELEASE spring-hateoas:0.16.0.RELEASE spring-data-rest-webmvc:2.2.2.RELEASE
在web.xml中:
休息 org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet 1
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
@RepositoryRestResource(collectionResourceRel =&#34; testcases&#34;,path =&#34; testcases&#34;) 公共接口ITestCaseRepository扩展了CrudRepository { 列出findByName(String name);
@Query("SELECT t from TestCase t WHERE LOWER(t.name) = LOWER(?1) AND t.type = ?2")
List<TestCase> myFindByNameANDType(String name, TestCaseType type);
List<TestCase> findByNameANDType(String name, TestCaseType type);
}
当我访问http://localhost:8080/rest时,我得到了这个拥抱错误:
HTTP状态500 - 处理程序处理失败;嵌套异常是java.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ser.std.MapSerializer.construct([Ljava / lang / String; Lcom / fasterxml / jackson / databind / JavaType; ZLcom / fasterxml / jackson / databind / jsontype / TypeSerializer; LCOM / fasterxml /杰克逊/数据绑定/ JsonSerializer; LCOM / fasterxml /杰克逊/数据绑定/ JsonSerializer; Ljava /郎/对象;)LCOM / fasterxml /杰克逊/数据绑定/ SER / STD / MapSerializer;
说明服务器遇到内部错误,导致无法完成此请求。
例外
org.springframework.web.util.NestedServletException:处理程序处理失败;嵌套异常是java.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ser.std.MapSerializer.construct([Ljava / lang / String; Lcom / fasterxml / jackson / databind / JavaType; ZLcom / fasterxml / jackson / databind / jsontype / TypeSerializer; LCOM / fasterxml /杰克逊/数据绑定/ JsonSerializer; LCOM / fasterxml /杰克逊/数据绑定/ JsonSerializer; Ljava /郎/对象;)LCOM / fasterxml /杰克逊/数据绑定/ SER / STD / MapSerializer; org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1287) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根本原因
java.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ser.std.MapSerializer.construct([Ljava / lang / String; Lcom / fasterxml / jackson / databind / JavaType; ZLcom / fasterxml / jackson / databind / jsontype / TypeSerializer; LCOM / fasterxml /杰克逊/数据绑定/ JsonSerializer; LCOM / fasterxml /杰克逊/数据绑定/ JsonSerializer; Ljava /郎/对象;)LCOM / fasterxml /杰克逊/数据绑定/ SER / STD / MapSerializer; org.springframework.hateoas.hal.Jackson2HalModule $ HalLinkListSerializer.serialize(Jackson2HalModule.java:169) org.springframework.hateoas.hal.Jackson2HalModule $ HalLinkListSerializer.serialize(Jackson2HalModule.java:109) com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:569) com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:597) com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142) com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118) com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1819) org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:231) org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:208) org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:161) org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:144) org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:71) org.springframework.data.rest.webmvc.ResourceProcessorHandlerMethodReturnValueHandler.handleReturnValue(ResourceProcessorHandlerMethodReturnValueHandler.java:172) org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:71) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
我不知道代码有什么问题,请帮助找出原因。
由于
谢
答案 0 :(得分:0)
可能您引用了错误版本的com.fasterxml.jackson
BR