Make sure map keys don't contain dots in the first place or configure an appropriate replacement!
遇到
Make sure map keys don't contain dots in the first place or configure an appropriate replacement!
解决方法
package com.tydt.raptor.sdk.configure; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.mongodb.MongoDbFactory; import org.springframework.data.mongodb.core.convert.DbRefResolver; import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver; import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; @Configuration public class MongoConfig { @Autowired private MongoDbFactory mongoFactory; @Autowired private MongoMappingContext mongoMappingContext; @Bean public MappingMongoConverter mongoConverter() throws Exception { DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoFactory); MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext); mongoConverter.setMapKeyDotReplacement("_"); mongoConverter.afterPropertiesSet(); return mongoConverter; } }