paulwong

MONGODB去除_class字段

加上此配置:

MongodbConfiguration.java
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.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
 
@Configuration
public class AppMongoConfig {
  @Autowired private MongoDbFactory mongoDbFactory;
 
  @Autowired private MongoMappingContext mongoMappingContext;
 
  @Bean
  public MappingMongoConverter mappingMongoConverter() {
 
    DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
    MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext);
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));
 
    return converter;
  }
}

posted on 2019-05-29 14:18 paulwong 阅读(1211) 评论(0)  编辑  收藏 所属分类: MONGODB


只有注册用户登录后才能发表评论。


网站导航: