我在 PostgreSQL DB + PostGIS 上使用 Spring + Hibernate Geometry
,它在 DB 上执行 CRUD 操作并使用 Jackson JSON 视图返回 JSON 输出。在我添加Geometry
. 当我检查对象时,搜索返回正确的输出,但是在创建结果的 JSON 表示时似乎存在问题,该结果具有Geometry
. 我得到这样的东西:
org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: This method does not support GeometryCollection arguments (through reference chain: java.util.ArrayList[0]->com.tutorial.jquery.model.State["geom"]->com.vividsolutions.jts.geom.MultiPolygon["boundary"]->com.vividsolutions.jts.geom.MultiLineString["boundary"]->com.vividsolutions.jts.geom.MultiPoint["boundary"]->com.vividsolutions.jts.geom.GeometryCollection["boundary"]); nested exception is org.codehaus.jackson.map.JsonMappingException: This method does not support GeometryCollection arguments (through reference chain: java.util.ArrayList[0]->com.tutorial.jquery.model.State["geom"]->com.vividsolutions.jts.geom.MultiPolygon["boundary"]->com.vividsolutions.jts.geom.MultiLineString["boundary"]->com.vividsolutions.jts.geom.MultiPoint["boundary"]->com.vividsolutions.jts.geom.GeometryCollection["boundary"])
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.writeInternal(MappingJacksonHttpMessageConverter.java:195)
at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:179)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:148)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:189)
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:69)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:746)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.codehaus.jackson.map.JsonMappingException: This method does not support GeometryCollection arguments (through reference chain: java.util.ArrayList[0]->com.tutorial.jquery.model.State["geom"]->com.vividsolutions.jts.geom.MultiPolygon["boundary"]->com.vividsolutions.jts.geom.MultiLineString["boundary"]->com.vividsolutions.jts.geom.MultiPoint["boundary"]->com.vividsolutions.jts.geom.GeometryCollection["boundary"])
at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:215)
at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:180)
at org.codehaus.jackson.map.ser.SerializerBase.wrapAndThrow(SerializerBase.java:128)
有人可以建议吗?