现在的位置: 首页 > 综合 > 正文

MongoDB Error

2013年12月01日 ⁄ 综合 ⁄ 共 866字 ⁄ 字号 评论关闭

①,org.springframework.core.convert.ConverterNotFoundException: No converter found capable of     converting from type org.joda.time.LocalDate to type java.lang.String
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:475)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:175)

at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:154)

解决方案:converter.afterPropertiesSet();

MappingMongoConverter converter = new MappingMongoConverter(mongoDbFactory, context);
converter.setTypeMapper(mapper);
converter.setCustomConversions(new CustomConversions(Arrays.asList(new TimeZoneReadConverter(),new TimeZoneWriteConverter())));
converter.afterPropertiesSet();
MongoTemplate template = new MongoTemplate(mongoDbFactory, converter);

抱歉!评论已关闭.