当前位置: 首页>>代码示例>>Java>>正文


Java MongoConverter类代码示例

本文整理汇总了Java中org.springframework.data.mongodb.core.convert.MongoConverter的典型用法代码示例。如果您正苦于以下问题:Java MongoConverter类的具体用法?Java MongoConverter怎么用?Java MongoConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MongoConverter类属于org.springframework.data.mongodb.core.convert包,在下文中一共展示了MongoConverter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mappingMongoConverter

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(MongoConverter.class)
public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory,
		MongoMappingContext context, BeanFactory beanFactory) {
	DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
	MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver,
			context);
	try {
		mappingConverter
				.setCustomConversions(beanFactory.getBean(CustomConversions.class));
	}
	catch (NoSuchBeanDefinitionException ex) {
		// Ignore
	}
	return mappingConverter;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:MongoDataAutoConfiguration.java

示例2: CustomMongodbSerializer

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
/**
 * Creates a new {@link CustomMongodbSerializer} for the given {@link MappingContext}.
 *
 * @param converter must not be {@literal null}.
 */
public CustomMongodbSerializer(MongoConverter converter) {

    Assert.notNull(converter, "MongoConverter must not be null!");

    this.mappingContext = converter.getMappingContext();
    this.converter = converter;
    this.mapper = new QueryMapper(converter);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:14,代码来源:CustomMongodbSerializer.java

示例3: convertEntityToJson

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
/**
 * Serializes an object into a string format that can be inserted into a MongoDB collection.
 * 
 * @param entity
 * @return
 */
public String convertEntityToJson(Object entity){
	MongoConverter converter = mongoTemplate.getConverter();
	DBObject dbObject = new BasicDBObject();
	converter.write(entity, dbObject);
	if (dbObject.containsField("_id") && dbObject.get("_id") == null){
		dbObject.removeField("_id");
	}
	if (dbObject.containsField("_class")){
		dbObject.removeField("_class");
	}
	return dbObject.toString();
}
 
开发者ID:oncoblocks,项目名称:centromere,代码行数:19,代码来源:ImportUtils.java

示例4: mongoConverter

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
@Bean(name = "mappingConverter")
public MongoConverter mongoConverter(MongoDbFactory mongoDbFactory) {
    MappingMongoConverter mappingMongoConverter =
            new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), new MongoMappingContext());
    return mappingMongoConverter;
}
 
开发者ID:sys-devel-d,项目名称:pimp,代码行数:7,代码来源:MongoConfig.java

示例5: mongoTemplate

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MongoTemplate mongoTemplate(MongoDbFactory mongoDbFactory,
		MongoConverter converter) throws UnknownHostException {
	return new MongoTemplate(mongoDbFactory, converter);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:MongoDataAutoConfiguration.java

示例6: getDefaultMongoConverter

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
private MongoConverter getDefaultMongoConverter(MongoDbFactory factory) {
    MappingMongoConverter converter = new MappingMongoConverter(factory, new MongoMappingContext());
    converter.afterPropertiesSet();
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));
    return converter;
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:7,代码来源:NaviMongoTemplateFactory.java

示例7: MongoTemplateWithRetry

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
public MongoTemplateWithRetry(MongoDbFactory dbFactory, MongoConverter mongoConverter) {
  super(dbFactory, mongoConverter);
}
 
开发者ID:hypoport,项目名称:robust-mongo-config,代码行数:4,代码来源:MongoTemplateWithRetry.java

示例8: MongoEntityTemplate

import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
public MongoEntityTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
    super(mongoDbFactory, mongoConverter);
    this.mapper = new QueryMapper(mongoConverter);
    mappingContext = mongoConverter.getMappingContext();
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:6,代码来源:MongoEntityTemplate.java


注:本文中的org.springframework.data.mongodb.core.convert.MongoConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。