記錄一下Junit測試MongoDB,獲取MongoTemplate

只是本身記錄一下,測試MongoDB幫助類時,沒有配置文件的測試測試

public 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是本身封裝的對查詢結果的處理
相關文章
相關標籤/搜索