0
期間不工作
我需要才達到dotReplacementKey春天引導和蒙戈:定製MappingMongoConverter DotReplacement
我使用的MongoDB這樣的配置:
@Configuration
public class MongoTemplateConfig {
@Value("${adserver_mongo_connection_string}")
private String databaseConnectionString;
@Bean
public MongoDbFactory mongoDbFactory() throws UnknownHostException {
MongoClientURI uri = new MongoClientURI(databaseConnectionString.trim());
return new SimpleMongoDbFactory(uri);
}
@Bean
public MongoTemplate mongoTemplate() throws UnknownHostException {
return new MongoTemplate(mongoDbFactory());
}
@Bean
public MappingMongoConverter mongoConverter(MongoDbFactory mongoFactory, MongoMappingContext mongoMappingContext) throws Exception {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoFactory);
MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext);
mongoConverter.setMapKeyDotReplacement(".");
return mongoConverter;
}
}
我做UPSERT如下: mongoTemplate.bulkOps(...).upsert(...)
而是經由調試運行期間我發現不同MappingMongoConverter用於而不是這個已配置爲@Bean
btw,如果@Inject MappingMongoConverter我從配置中獲取合適的bean,keyDotReplacement =「。」 但看起來像Spring Boot使用另一個引擎蓋
P.S.我已經看到了這question沒有正確的答案,但mongoConverter.afterPropertiesSet()
嘗試,顯然它不工作,以及