当前位置:Gxlcms > 
数据库问题 > 
记录一下Junit测试MongoDB,获取MongoTemplate
                     
                    
                        记录一下Junit测试MongoDB,获取MongoTemplate
                        
                            时间:2021-07-01 10:21:17
                            帮助过:3人阅读
							                        
                     
                    
                    
                     class HelperTest {
    
    MongoTemplate template;
    
    @Before
    public void init() {
        MongoDbFactory facotry = 
new SimpleMongoDbFactory(
new MongoClient("127.1.1.1", 27017), "test"
);
        template = 
new MongoTemplate(facotry);
    }
    
    @Test
    public void test() {
        AggregationProxyResults<Document> results = MongodbQueryHelper.queryHotel("test", 1, template, Document.
class, 
                LocalDateTime.of(2018, 04, 11, 00, 00), LocalDateTime.of(2018, 04, 12, 00, 00
));
        System.out.println(results.list());
    }
 
AggregationProxyResults是自己封装的对查询结果的处理
记录一下Junit测试MongoDB,获取MongoTemplate
标签:文件   imp   for   god   bsp   lis   lda   style   time