地圖鍵代碼產品包含點,但未配置替換!確保地圖鍵首先不包含點或配置適當的替換!MongoDB-Escape dots'。'在地圖鍵中]
org.springframework.data.mapping.model.MappingException:映射鍵foo.bar.key包含點但未配置替換!確保地圖鍵首先不包含點或配置適當的替換! 在org.springframework.data.mongodb.core.convert.MappingMongoConverter.potentiallyEscapeMapKey(MappingMongoConverter.java:622) 在org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:586) 在org.springframework.data.mongodb.core.convert.MappingMongoConverter.createMap(MappingMongoConverter.java:517) 在org.springframework.data.mongodb.core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:424) 的組織。 springframework.data.mongodb.core.convert.MappingMongoConverter $ 3.doWithPersistentProperty(MappingMongoConverter.java:386) at org.springframework.data.mongodb.core.convert.MappingMongoConverter $ 3.doWithPersistentProperty(MappingMongoConverter.java:373) at org。 springframework.d ata.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:257) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:373) at org.springframework.data.mongodb。 core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:451) at org.springframework.data.mongodb.core.convert.MappingMongoConverter $ 3.doWithPersistentProperty(MappingMongoConverter.java:386) at org.springframework.data.mongodb.core .convert.MappingMongoConverter $ 3.doWithPersistentProperty(MappingMongoConverter.java:373) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:257) at org.springframework.data.mongodb.core.convert。 MappingMongoConverter.writeInternal(MappingMongoC onverter.java:373) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:451) at org.springframework.data.mongodb.core.convert.MappingMongoConverter $ 3.doWithPersistentProperty(MappingMongoConverter .java:386) at org.springframework.data.mongodb.core.convert.MappingMongoConverter $ 3.doWithPersistentProperty(MappingMongoConverter.java:373) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java: 257) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:373) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:345) at org.springframe在org.springframework上的org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:77) 上的work.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:310) 。 data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:859) at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:806) at org.springframework.data.mongodb.core。 MongoTemplate.save(MongoTemplate.java:794)
當我們嘗試插入值時,會發生這種情況。我們如何解決這個問題?
這是我的課
@Configuration
@EnableMongoRepositories("net.ooo.hepsiburada.**.repository")
@Profile(Constants.SPRING_PROFILE_CLOUD)
public class CloudMongoDbConfiguration extends AbstractMongoConfiguration {
private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class);
@Inject
private MongoDbFactory mongoDbFactory;
@Bean
public ValidatingMongoEventListener validatingMongoEventListener() {
return new ValidatingMongoEventListener(validator());
}
@Bean
public LocalValidatorFactoryBean validator() {
return new LocalValidatorFactoryBean();
}
@Bean
public CustomConversions customConversions() {
List<Converter<?, ?>> converterList = new ArrayList<>();;
converterList.add(DateToZonedDateTimeConverter.INSTANCE);
converterList.add(ZonedDateTimeToDateConverter.INSTANCE);
converterList.add(DateToLocalDateConverter.INSTANCE);
converterList.add(LocalDateToDateConverter.INSTANCE);
converterList.add(DateToLocalDateTimeConverter.INSTANCE);
converterList.add(LocalDateTimeToDateConverter.INSTANCE);
return new CustomConversions(converterList);
}
@Override
protected String getDatabaseName() {
return mongoDbFactory.getDb().getName();
}
@Override
public Mongo mongo() throws Exception {
return mongoDbFactory().getDb().getMongo();
}
}
我在哪裏可以進行此修改? – mark
看到這個問答:http://stackoverflow.com/questions/35598595/how-to-customize-mappingmongoconverter-setmapkeydotreplacement-in-spring-boot –
我添加了我的課程。在那個班裏面?但是如何? – mark