web项目整合MongoDb出现No converter found capable of converting from org.bson.types.ObjectId to type Long异常
2017-10-05 01:25
771 查看
Spring、SpringMVC、MyBatis框架整合 MongoDb ,启动web项目时出现异常,项目不能运行,查看原因是出现如下异常:
with root cause org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.types.ObjectId to type java.lang.Long
异常堆栈如下:
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [springMvcDispatcherServlet] in context with path [/conference] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.types.ObjectId to type java.lang.Long] with root cause
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.types.ObjectId to type java.lang.Long
解决方法:
Spring使用MongoDb帮助文档
在MongoDb里要求每个文档都需要有
如果1个字段加上了
如果java对象中没有
with root cause org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.types.ObjectId to type java.lang.Long
异常堆栈如下:
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [springMvcDispatcherServlet] in context with path [/conference] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.types.ObjectId to type java.lang.Long] with root cause
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.types.ObjectId to type java.lang.Long
解决方法:
Spring使用MongoDb帮助文档
在MongoDb里要求每个文档都需要有
_id字段,java类中有如下情况会被映射为_id字段
如果1个字段加上了
@Id (org.springframework.data.annotation.Id)注解,那么将bean保存到数据库时就会把该字段映射为文档中的_id字段
如果java对象中没有
@Id注解,名字为id 的字段将会被映射为文档中的_id字段
相关文章推荐
- 使用Spring Cloud微服务框架进行多个微服务整合时出现No converter found for return value of type:xxx异常信息
- org.springframework.data.mapping.model.MappingException: No id property found for object of type
- HttpMessageConverter配置javaconfig(未配置异常:No converter found for return value of type)
- 关于ssm分布式项目中的No converter found for return value of type问题
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill
- 170524、java.lang.IllegalArgumentException: No converter found for return value of type异常解决
- No converter found for return value of type: class org.json.JSONArray解决方法
- No code "EPSG:4326" from authority "EPSG" found for object of type "EngineeringCRS"
- 使用CGlib出现java.lang.NoClassDefFoundError: org/objectweb/asm/Type异常
- ssh整合中,hibernate3.6.0异常java.lang.NoClassDefFoundError: org/objectweb/asm/Type
- 异常:There was no TypeHandler found for parameter id of statement
- SLF4J: Failed toString() invocation on an object of type [org.eclipse.jetty.websocket.server......
- spring3.0.5 和hibernate3.6整合问题之java.lang.ClassNotFoundException: org.objectweb.asm.Type
- 在Spring Cloud框架整合微服务时出现的org.springframework.web.HttpMediaTypeNotSupportedException异常问题
- idea 出现Could not autowire. No beans of 'xxxxMapper' type found. 安装 Mybatis Plugin 插件
- Spring No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency
- No converter found for return value of type: class java.util.HashMap
- Eclipse在导入项目时出现“No projects found to import”解决办法
- 170616、解决 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type