MongoDB——JavaAPI详解

2023-05-16

环境配置

引入MongoDB驱动:

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.8.2</version>
</dependency>

连接数据库

public class BaseDemo {
    public static void main(String[] args) {
        //创建连接对象
        MongoClient client = new MongoClient("127.0.0.1", 27017);
        //获取数据库
        MongoDatabase db = client.getDatabase("test");
        //获取集合
        MongoCollection<Document> book = db.getCollection("book");
        client.close();
    }
}

封装成工具类:

public class MongoDBUtil {

    private  static MongoClient client = null;

    static {
        if (client == null) {
            client = new MongoClient("127.0.0.1", 27017);
        }
    }

    //获取数据库
    public static MongoDatabase getDatabase(String dbName) {
        return client.getDatabase(dbName);
    }

    //获取集合
    public static MongoCollection getCollection(String dbName, String collName){
        return getDatabase(dbName).getCollection(collName);
    }

    public static void main(String[] args) {
        MongoDBUtil.getCollection("test", "person");
        System.out.println("ok");
    }
}

带用户认证的工具类:

public class MongoDBAuthUtil {

    private static MongoClient client = null;

    static {
        if (client == null) {
            //创建一个封装用户认证信息
            MongoCredential credential = MongoCredential.createCredential("root", "test", "123456".toCharArray());
            //封装mongoDB的地址与端口
            ServerAddress address = new ServerAddress("127.0.0.1", 27017);
            client = new MongoClient(address, credential, MongoClientOptions.builder().build());
        }
    }

    //获取数据库
    public static MongoDatabase getDatabse(String dbName){
        return client.getDatabase(dbName);
    }

    //获取集合
    public static MongoCollection getCollection(String dbName, String collName) {
        MongoDatabase databse = getDatabse(dbName);
        return databse.getCollection(collName);
    }

    public static void main(String[] args) {
        MongoDBAuthUtil.getDatabse("test");
        System.out.println("ok");
    }
}

带用户认证的连接池:

public class MongoDBAuthPoolUtil {

    private static MongoClient client = null;

    static {
        if (client == null) {
            MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
            builder.connectionsPerHost(10);//每个地址的最大连接数
            builder.connectTimeout(5000);//连接超时时间
            builder.socketTimeout(5000);//读写操作超时时间
            MongoCredential credential = MongoCredential.createCredential("root", "test", "123456".toCharArray());
            ServerAddress address = new ServerAddress("127.0.0.1", 27017);
            client = new com.mongodb.MongoClient(address, credential, builder.build());
        }
    }

    //获取MongoDB数据库
    public static MongoDatabase getDatabase(String dbName) {
        return client.getDatabase(dbName);
    }

    //获取MongoDb集合
    public static MongoCollection getCollection(String dbName, String collName) {
        return getDatabase(dbName).getCollection(collName);
    }


    //创建集合
    public static void createCollection(String dbName, String collName) {
        getDatabase(dbName).createCollection(collName);
    }

    //删除集合
    public static void dropCollection(MongoCollection coll) {
        coll.drop();
    }
}

集合操作

public class CollectionDemo {
    public static void main(String[] args) {
        // 创建 MongoDB 连接
        MongoClient mongo = new MongoClient( "localhost" , 27017 );

        //访问数据库
        MongoDatabase db = mongo.getDatabase("test");

        //创建集合
        //CreateCollectionOptions可以指定参数,比如最大文档数、文档大小等等...
        CreateCollectionOptions cco = new CreateCollectionOptions();
        db.createCollection("ceshi", cco);

        //检索集合
        MongoCollection<Document> col = db.getCollection("ceshi");

        //查看所有集合
        MongoIterable<String> nameList = db.listCollectionNames();
        for (String name : nameList)
            System.out.println(name);
        ListCollectionsIterable<Document> docList = db.listCollections();
        for (Document doc : docList)
            System.out.println(doc.toString() + " " + doc.size());

        //删除集合
        col.drop();

        mongo.close();
    }
}

文档操作

1、插入

public class InsertDocument {


    public static void main(String[] args) {
        InsertDocument insertDocument = new InsertDocument();
        insertDocument.insertSingleDocument();
        insertDocument.insertManyDocument();
    }


    /**
     * 添加单个文档
     */
    public void insertSingleDocument() {
        //获取集合
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        // {} ---> Dcument
        // append(Stirng key, Object value) ----> {key: value}
        Document document = new Document();
        document.append("name", "三国演义").append("price", 22.6);
        //插入参数配置对象
        InsertOneOptions iop = new InsertOneOptions();
        collection.insertOne(document, iop);
    }

    /**
     * 文档的批量添加
     */
    public void insertManyDocument() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        List<Document> list = new ArrayList<Document>();
        for (int i = 0; i < 5; i++) {
            Document document = new Document();
            document.append("name", "哈利波特" + i)
                    .append("price", 66.3 + i);
            list.add(document);
        }
        //插入参数配置对象
        InsertManyOptions imo = new InsertManyOptions();
        collection.insertMany(list, imo);
    }
}

2、查询文档

public class FindDocment {

    public static void main(String[] args) {
        FindDocment findDocment = new FindDocment();
        // findDocment.selectDocumentById();
        // findDocment.selectDocumentConditionByGt();
        // findDocment.selectDocumentConditionByType();
        // findDocment.selectDocumentConditionByIn();
        // findDocment.selectDocumentConditionByRegex();
        // findDocment.selectDocumentConditionUseAnd();
        // findDocment.selectDocumentConditionUseOr();
        // findDocment.selectDocumentConditionUseAndOr();
        findDocment.selectDocumentSorting();
    }

    /**
     * 根据_id查询文档
     * db.class.find("1")
     */
    public void selectDocumentById() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "class");
        FindIterable<Document> iterable = collection.find(Filters.eq("_id", 1));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            Document document = cursor.next();
            System.out.println(document.get("_id"));
            System.out.println(document.get("name"));
            System.out.println(document.get("student"));
        }
    }

    /**
     * 查询多个文档
     * db.book.find({price:{$gt: 10}})
     */
    public void selectDocumentConditionByGt() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.gt("price", 10));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }

    /**
     * 查询多个文档 $type
     * db.book.find({price: {$type: "number"}})
     */
    public void selectDocumentConditionByType() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.type("price", "number"));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }

    /**
     * 查询多个文档
     * db.book.find({name: {$in:["三国演义", "说文解字"]}})
     */
    public void selectDocumentConditionByIn() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.in("name", "三国演义", "说文解字"));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }

    /**
     * 查询多个文档
     * db.book.find({name: {$regex: /^哈利波特/}})
     */
    public void selectDocumentConditionByRegex() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.regex("name", Pattern.compile("^哈利波特")));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }

    /**
     * 逻辑运算符 $and
     * db.book.find({$and:[{name: {$regex:/^哈利波特/}}, {price: 11.1}]})
     */
    public void selectDocumentConditionUseAnd() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.and(Filters.regex("name", Pattern.compile("^哈利波特")),
                Filters.eq("price", 11.1)));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }

    }

    /**
     * 逻辑运算符 $or
     * db.book.find($or: [{name: {$regex:/^哈利波特/}}, {price:22.6}])
     */
    public void selectDocumentConditionUseOr() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.or(Filters.regex("name", Pattern.compile("^哈利波特")),
                Filters.eq("price", 22.6)));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }

    /**
     * 逻辑运算符 $and和$or联合使用
     * db.book.find({$or: [{$and:[{name:"说文解字"},{price:23.4}]},{name:{$regex:"^哈利波特"}}]})
     */
    public void selectDocumentConditionUseAndOr() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find(Filters.or(
                Filters.and(Filters.eq("name", "说文解字"), Filters.eq("price", 23.4)),
                Filters.regex("name", Pattern.compile("^哈利波特"))
        ));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }

    /**
     * 排序处理
     * db.book.find().sort(price: -1)
     */
    public void selectDocumentSorting() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        FindIterable<Document> iterable = collection.find().sort(new Document("price", -1));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }
}

3、更新文档

public class UpdateDocument {


    public static void main(String[] args) {
        UpdateDocument updateDocument = new UpdateDocument();
        updateDocument.updateSingleDocumentSingleKey();
        updateDocument.updateSingleDocumentManyKey();
        updateDocument.updateManyDocumentSingleKey();
        updateDocument.updateManyDocumentManyKey();
        updateDocument.updateDocumentArray();
    }

    /**
     * 更新单个文档单个键
     * db.book.update({name:{$eq:"哈利波特1"}, {$set: {price:99.9}}})
     */
    public void updateSingleDocumentSingleKey() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        //更新文档,下面二者等价
        //collection.updateOne(Filters.eq("name", "哈利波特1"), new Document("$set", new Document("price", 99.9)));
        collection.updateOne(Filters.eq("name", "哈利波特1"), Updates.set("price", 99.9));
    }

    /**
     * 更新单个文档多个键
     * db.book.update({name:{$eq:"哈利波特1"}, {$set:{price:111, count:50}}})
     */
    public void updateSingleDocumentManyKey() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        // 下面二者等价
        // collection.updateOne(Filters.eq("name", "哈利波特1"), new Document("$set", new Document("price", 111).append("count", 50)));
        UpdateResult updateResult = collection.updateOne(Filters.eq("name", "哈利波特1"), Updates.combine(Updates.set("price", 111), Updates.set("count", 50)));
        System.out.println(updateResult.getMatchedCount());
    }

    /**
     * 跟新多个文档中的单个键
     * db.book.update({name:{$regex:"^哈利波特"}}, {$set: {count: 88}})
     */
    public void updateManyDocumentSingleKey() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        collection.updateMany(Filters.regex("name", "^哈利波特"), new Document("$set", new Document("count", 88)));
    }

    /**
     * 更新多个文档中的多个键
     * db.book.update({name:{$regex: "^哈利波特"}}, {$set: {count: 99, price:11.1}})
     */
    public void updateManyDocumentManyKey() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");
        collection.updateMany(Filters.regex("name", "^哈利波特"), new Document("$set", new Document("count", 99).append("price", 11.1)));
    }


    /**
     * 跟新文档中的数组
     * db.array.update({_id:1}, {$push: {char: z}})
     */
    public void updateDocumentArray() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "array");
        collection.updateOne(Filters.eq("_id", 1), new Document("$push", new Document("char", "z")));
    }

}

4、删除文档

public class RemoveDocument {
    public static void main(String[] args) {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");

        //删除单个文档
        DeleteResult deleteResult = collection.deleteOne(Filters.eq("name", "tom"));
        System.out.println(deleteResult.getDeletedCount());

        //删除多个文档
        DeleteResult dr = collection.deleteMany(Filters.regex("name", Pattern.compile("^哈利波特")));
        System.out.println(dr.getDeletedCount());
    }
}

5、Date相关

public class DateUtil {


    /**
     * Date To String
     */
    public static String dateToString(String parten, Date date) {
        SimpleDateFormat format = new SimpleDateFormat(parten);
        return format.format(date);
    }

    /**
     * String To Date
     */
    public static Date stringToDate(String parten, String date) {
        SimpleDateFormat format = new SimpleDateFormat(parten);
        Date d = null;
        try {
            d = format.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return d;
    }
}
public class DateDocument {

    public static void main(String[] args) {
        DateDocument dateDocument = new DateDocument();
        dateDocument.insertDocumentSystemDate();
        dateDocument.selectDocumentDateUseEq();
    }


    /**
     * 插入系统当前日期
     * db.birthday.insert({_id:1, datetime: new Date()})
     */
    public void insertDocumentSystemDate() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "birthday");
        collection.insertOne(new Document("_id", 1).append("datetime", new Date()));
    }

    /**
     * 查询日期;查询生日为2019-05-01 13:32:13的用户信息
     * db.birthday.find({datetime: {$eq:new Date("2019-05-01 13:32:13")}})
     */
    public void selectDocumentDateUseEq() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "birthday");
        Date date = DateUtil.stringToDate("yyyy-MM-dd HH:mm:ss", "2019-05-01 13:32:13");
        FindIterable<Document> iterable = collection.find(Filters.eq("birthday", date));
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }
}

6、聚合

public class AggregateDocument {
    public static void main(String[] args) {
        AggregateDocument aggregateDocument = new AggregateDocument();
        aggregateDocument.selectDocumentAggregateCount();
        aggregateDocument.selectDocumentAggregateSum();
    }

    /**
     * 查询集合中的文档数量
     * db.book.aggregate([{$group:{_id:null, count:{$sum:1}}}])
     */
    public void selectDocumentAggregateCount() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");

        Document sum = new Document();
        sum.put("$sum", 1);
        Document count = new Document();
        count.put("_id", null);
        count.put("count", sum);

        Document group = new Document();
        group.put("$group", count);

        List<Document> list = new ArrayList<Document>();
        list.add(group);

        AggregateIterable iterable = collection.aggregate(list);
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()){
            System.out.println(cursor.next());
        }
    }

    /**
     * 查询集合中所有price键中的值的总和
     * db.books.aggregate([{$group: {_id:null, totalPrice: {$sum:"$price"}}}])
     */
    public void selectDocumentAggregateSum() {
        MongoCollection collection = MongoDBUtil.getCollection("test", "book");

        Document sum = new Document("$sum", "$price");
        Document totalPrice = new Document("totalPrice", sum).append("_id", null);
        Document group = new Document("$group", totalPrice);
        List<Document> list = new ArrayList<Document>();
        list.add(group);
        AggregateIterable<Document> iterable = collection.aggregate(list);
        MongoCursor<Document> cursor = iterable.iterator();
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MongoDB——JavaAPI详解 的相关文章

  • 如何使用 java 执行此 MongoDB 查询?

    我必须写一个简单的MongoDB查询使用java但我做不到 mongo 查询如下所示 db yourCollection find where this startDate lt this endDate 我必须使用以下命令编写上述查询Qu
  • 多个 2dsphere 索引,不确定要运行 geoNear 中的哪一个

    我在用 geoNear and near在 MongoDB 的聚合内部 我有将我的 MongoDB 数据库托管到 mlabs 中 And 我本地一切正常 但不知道为什么当我部署应用程序时出现以下错误 geoNear 命令失败 ok 0 0
  • 如何在docker compose中运行mongodb副本集

    我尝试在我的 Mac 中使用 mongodb community 在本地运行 mongodb 副本集MongoDB 文档 https docs mongodb com manual tutorial convert standalone t
  • Meteor 独特客户端集合的发布/订阅策略

    使用 Meteor 我想知道如何最好地处理共享相同服务器端数据库集合的不同客户端集合 考虑以下示例 我有一个User集合 在我的客户端我有一个好友用户列表我有一个搜索功能 可以对整个用户数据库执行查询 返回一个与查询匹配的用户名列表 在发布
  • Mongodb 聚合使用 $group 两次

    我在 mongo 中有一堆文档 其结构如下 id number 2 colour id name Green hex 00ff00 position id name Defence type position ageGroup id nam
  • mongodb - 一个集合中的许多文档与多个集合中的许多文档

    我使用 mongodb 作为数据库存储 我的网络应用程序必须收集用户响应 用户响应是 mongodb 中的文档 或 sql 中的一行 一个文档的长度大约是10 200 用户响应被分类 仅到一个类别 每个类别的用户响应数在100 5000之间
  • Mongodb聚合框架:$group是否使用索引?

    我正在尝试使用聚合框架 match and group阶段 做 group阶段使用索引数据 我正在使用最新的可用 mongodb 版本 2 5 4 group不使用索引数据 来自 mongoDBdocs http docs mongodb
  • Mongoose 多个连接

    目前我的连接有这个代码猫鼬 js var mongoose require mongoose var uriUtil require mongodb uri var mongodbUri mongodb localhost db name
  • MongoDB - 编辑器变量 - MongoDB shell - Windows 7

    EDITOR 变量功能真的可以在 Windows 7 上使用吗 我正在读一篇文章 说一旦我们设置了 EDITOR 变量在 mongorc js 中 我们只需在 shell 中输入 编辑变量名 and var name将被加载到编辑器中 在我
  • MongoDB:如何使用单个命令更新多个文档?

    我惊讶地发现以下示例代码仅更新单个文档 gt db test save id 1 foo bar gt db test save id 2 foo bar gt db test update foo bar set test success
  • 在 MongoDB 中查找 7 天前的记录

    我有一个包含对象的集合 如下所示 1 id ObjectId 551c6605e4c6ac495c923aab sender id ObjectId 551c6605e4c6ac495c923aac rep sender id 38 sen
  • mongodb在windows下无法启动?

    当我尝试在命令行上使用命令 mongod exe 启动 mongodb 时 它会抛出以下错误 C mongodb win32 x86 64 2 0 6 bin gt mongod exe mongod exe help for help a
  • 聚合和展开数组,但保留顶级键

    假设我的收藏中有以下文档Classes收藏家 id ObjectId 5df58d45244a850d54b922c8 mentors numOfMentors NumberInt 1 mentorList ObjectId 5c9ba63
  • Mongoose嵌入式文档更新

    我在嵌入式文档更新方面遇到问题 我定义的架构 var Talk new Schema title type String required true content type String required true date type D
  • 检索 mongoDB 文档中的空数组或 null

    我有我学校所有学生的收藏 每个文档都有一个sports列出每个学生从事的运动的数组属性 但该属性可能显示为sports or sports null或者根本不出现 如何检索属于上述三种情况之一的所有文件 如何向只有一项运动但未表示为数组的学
  • Mongodb 数据库上的 SASL 身份验证失败

    我在尝试使用 PHP Mongodb 驱动程序连接到 Mongodb 时遇到问题 实际上我有一个名为 LRS 的数据库 它有一个名为 juano 的用户 在我的设置文件中带有密码 12345 我确信我编写了正确的配置 但是当我在 Larav
  • 为 Meteor 数据创建编号列表

    有没有办法获取 Meteor 集合中项目的编号列表的 编号 我知道我可以在 html 中做到这一点 但我觉得如果我可以在 spacebars 中放置一些东西 那么样式会更容易 如果我可以使用更好的术语 请告诉我 像这样的东西 前 20 部电
  • Pymongo 批量插入

    我正在尝试批量插入文档 但批量插入时不会插入超过 84 个文档 给我这个错误 in insert pymongo errors InvalidOperation cannot do an empty bulk insert 是否可以批量插入
  • mongodb 聚合 - 累积字段的不同组值

    如果我有Player表格文件 name String score Int 我有Group文档 其中组代表玩家列表 groupName String players ObjectID 玩家可以属于多个组 我想做一个聚合Player文档 按以下
  • 使用填充方法在 sails mongo 中进行深层关联?

    我是 sails js 的新手 我正在使用 sails js 与 Mongodb 我在我的 sails 应用程序中使用 populate 进行深层关联时遇到问题 我有这样的关系 Category has many to many relat

随机推荐

  • ssl 服务器证书,客户端信任证书

    Secure Socket Layer SSL technology allows web browsers and web servers to communicate over a secure connection In this s
  • Laravel-admin 七牛云上传文件到七牛云出现卡顿失败情况

    由于所做项目需要管理后台众多 xff0c 所以选择了Laravel admin后台框架进行开发 节省了权限控制以及页面处理等问题的时间 Laravel admin文档地址 http laravel admin org docs zh 由于项
  • linux分区btrfs,系统基础之Btrfs文件系统详解

    btrfs文件系统 技术预览版 centos7 描述 Btrfs B tree Butter FS Better fs GPL授权 Orale 2007 写实复制特性 Cow cp reflink 只能在btrfs文件系统中使用 想取代ex
  • UITableView 总结

    UITableView 1 重用代理 64 interface ViewController UIViewController lt UITableViewDelegate UITableViewDataSource gt 2 定义 tab
  • 【转】ASP.Net2.0 AJAX Extensions 1.0的安装

    文章出处 xff1a DIY部落 http www diybl com course 4 webprogram asp net asp netshl 2008828 138230 html 以前一直没有去应用ajax xff0c 这2天用了
  • pip国内源

    pip 国内源 xff1a 清华 xff1a https pypi tuna tsinghua edu cn simple 阿里云 xff1a http mirrors aliyun com pypi simple 中国科技大学 https
  • 视频教程-C语言入门篇-C/C++

    C语言入门篇 23年C 43 43 语言编程经验 xff0c 经历过多个行业的开发项目包括网络安全 xff0c 网络游戏 xff0c 通信行业等等 xff0c 多年的摸爬滚打使自身具备了深厚的开发实力和实战经验 王健伟 98 00 立即订阅
  • ubuntu - 如何以root身份使用图形界面管理文件?

    nautilus 是gnome的文件管理器 xff0c 但是如果不是root账号下 xff0c 权限受限 xff0c 我们可以通过以下方式以root权限使用 xff01 一 xff0c 快捷键 ctrl 43 alt 43 t 调出shel
  • debian添加删除用户

    debian添加删除用户 增加普通用户 命令 xff1a adduser abc passwd abc exit 用abc登录 etc passwd中保存了用户信息 LINUX创建用户的命令 useradd g test d home te
  • MongoDB——副本集的同步、选举和回滚

    1 同步 复制用于在多台服务器之间备份数据 MongoDB的复制功能是使用操作日志oplog实现的 xff0c 操作日志包含了主节点的每一次写操作 oplog是主节点的locl数据库中的一个固定集合 备份节点通过查询这个集合就可以知道需要进
  • ftp (文件传输协议)

    ftp xff08 文件传输协议 xff09 锁定 本词条由 科普中国 百科科学词条编写与应用工作项目 审核 FTP 是File Transfer Protocol xff08 文件传输协议 xff09 的英文简称 xff0c 而中文简称为
  • SQL Server 中的 JSON 数据

    下面是 JSON 文本的示例 34 name 34 34 John 34 34 skills 34 34 SQL 34 34 C 34 34 Azure 34 34 name 34 34 Jane 34 34 surname 34 34 D
  • 去除地址栏带#的问题

    vue cil搭建的项目 第一步 xff1a 找到目录下router js文件 第二步 xff1a 在new Router xff08 routes xff1a xff09 中添加mode属性 xff0c 默认mode是hash expor
  • 如何给自己的Python项目制作安装包

    Packaging Python Projects 本教程将指导您如何打包一个简单的Python项目 它将向您展示如何添加必要的文件和结构来创建包 xff0c 如何构建包以及如何将其上载到Python包索引 A simple project
  • linux安装解压工具gzip,笔记6 压缩工具(gzip,bzip2,xz,zip,tar)。

    压缩打包 常见的压缩文件 windows rar zip 7z Linux zip gz bz2 xz tar gz tar bz2 tar xz gzip压缩工具 不能压缩目录 gzip压缩后边直接跟文件名就可以 xff0c gunzip
  • 洛谷 P3367 【模板】并查集

    P3367 模板 并查集 题目描述 如题 xff0c 现在有一个并查集 xff0c 你需要完成合并和查询操作 输入输出格式 输入格式 xff1a 第一行包含两个整数N M xff0c 表示共有N个元素和M个操作 接下来M行 xff0c 每行
  • js计算器(正则)

    lt doctype html gt lt html gt lt head gt lt meta charset 61 34 utf 8 34 gt lt title gt 我的计算器 lt title gt lt style gt mar
  • MySQL 分组后取每组前N条数据

    与oracle的 rownumber over partition by xxx order by xxx 语句类似 xff0c 即 xff1a 对表分组后排序 创建测试emp表 DROP TABLE IF EXISTS emp CREAT
  • archlinux 安装搜狗输入法

    安装可能需要 archlinuxcn 的源 xff0c 我这里已经配置好了 一 安装 fcitx fcitx configtool fcitx im pacman S fcitx fcitx configtool fcitx im 二 在
  • MongoDB——JavaAPI详解

    环境配置 引入MongoDB驱动 xff1a span class token tag span class token tag span class token punctuation lt span dependency span sp