MongoOperations operations = MongoTemplateFactory.getMongoByName("数据库名");
MongoCollection source = operations.getCollection(collectionName);
source.aggregate(Arrays.asList(out(collectionName_copy))).toCollection();
复制的集合与原集合数据一致。
即使collectionName_copy 中的数据会新增,修改,删除后,再次复制后,也会跟collectionName 中数据一致。