当前位置: 首页 > news >正文

MongoDB - 组合聚合阶段:$group、$match、$limit、$sort、$skip、$project、$count

文章目录

    • 1. $group
    • 2. $group-> $project
        • 2.1 $group
        • 2.2 $group-> $project
        • 2.3 SpringBoot 整合 MongoDB
    • 3. $match-> $group -> $match
        • 3.1 $match
        • 3.2 $match-> $group
        • 3.3 $match-> $group-> $match
        • 3.4 SpringBoot 整合 MongoDB
    • 4. $match-> $group-> $project-> $sort-> skip-> $limit
        • 4.1 $match
        • 4.2 $match-> $group
        • 4.3 $match-> $group-> $project
        • 4.4 $match-> $group-> $project-> $sort
        • 4.5 $match-> $group-> $project-> $sort-> $skip
        • 4.5 $match-> $group-> $project-> $sort-> $skip-> $limit
        • 4.6 SpringBoot 整合 MongoDB
    • 5. $group-> $project
        • 5.1 $group 多字段分组聚合
        • 5.2 $group-> $project
        • 5.3 $group-> $project-> $sort
        • 5.4 $group-> $project-> $sort-> $limit
        • 5.5 SpringBoot 整合 MongoDB

根据工作中常见的业务需求,构造了一些场景来练习 mongodb 聚合阶段的使用。

1. $group

$group 根据单个字段对文档进行分组。

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "A", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "B", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "C", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "C", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "D", "category": "Clothing", "quantity": 12, "price": 700 }
])

根据 category 字段对文档进行分组并计算每个分组内文档的数量:

db.sales.aggregate([{$group : {_id : "$category",count: { $sum: 1 }}}
])

执行 $group 聚合阶段后输出的文档:

// 1
{"_id": "Clothing","count": 4
}// 2
{"_id": "Electronics","count": 4
}

SpringBoot整合MongoDB实现:

// 输入文档
@Data
@Document(collection = "sales")
public class Sales {@MongoIdprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档
@Data
public class AggregationResult {private int _id;private int count;
}// 聚合操作
@Test
public void aggregateTest() {// $group 聚合阶段GroupOperation group = Aggregation.group("category").count().as("count");// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(group);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(_id=Clothing, count=4)//AggregationResult(_id=Electronics, count=4)
}

2. $group-> $project

$group 单字段分组 + $project 排除字段 + $project 重命名字段

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "A", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "B", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "C", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "C", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "D", "category": "Clothing", "quantity": 12, "price": 700 }
])
2.1 $group

执行 $group 聚合阶段后输出的文档:

db.sales.aggregate([{$group : {_id : "$category",count: { $sum: 1 }}}
])
// 1
{"_id": "Clothing","count": 4
}// 2
{"_id": "Electronics","count": 4
}
2.2 $group-> $project

执行 g r o u p + group+ group+project 聚合阶段后输出的文档:

db.sales.aggregate([// $group阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$category",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,并将count字段的名称重命名newCount字段{$project : {_id : 0,newCount: "$count"}}
])
// 1
{"newCount": 4
}// 2
{"newCount": 4
}
2.3 SpringBoot 整合 MongoDB
// 输入文档实体类
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体类
@Data
public class AggregationResult {private String newCount;
}// 聚合操作
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $group 聚合阶段GroupOperation group = Aggregation.group("category").count().as("count");// $project 聚合阶段ProjectionOperation project = Aggregation.project().andExclude("_id").and("count").as("newCount");// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(group,project);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(newCount=4)//AggregationResult(newCount=4)}
}

3. $match-> $group -> $match

$match 根据条件筛选文档+ $group 根据单字段分组文档 + $match 筛选分组后的文档

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "A", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "B", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "C", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "C", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "D", "category": "Clothing", "quantity": 12, "price": 700 }
])
3.1 $match

执行 $match 聚合阶段输出的文档为:

db.sales.aggregate([// 第一阶段:筛选出 price>=300 的文档{$match : {"price": { $gte: 300 }}}
])
// 1
{"_id": 3,"product": "C","category": "Electronics","quantity": 5,"price": 300
}// 2
{"_id": 4,"product": "D","category": "Electronics","quantity": 10,"price": 500
}// 3
{"_id": 5,"product": "A","category": "Clothing","quantity": 8,"price": 500
}// 4
{"_id": 7,"product": "C","category": "Clothing","quantity": 8,"price": 600
}// 5
{"_id": 8,"product": "D","category": "Clothing","quantity": 12,"price": 700
}
3.2 $match-> $group

执行 m a t c h + match+ match+group 聚合阶段是输出的文档为:

db.sales.aggregate([// 第一阶段:筛选出 price>=300 的文档{$match : {"price": { $gte: 300 }}},// 第二阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$category",count: { $sum: 1 }}}
])
// 1
{"_id": "Clothing","count": 3
}// 2
{"_id": "Electronics","count": 2
}
3.3 $match-> $group-> $match

执行 m a t c h + match+ match+group+$match 聚合阶段是输出的文档为:

db.sales.aggregate([// 第一阶段:筛选出 price>=300 的文档{$match : {"price": { $gte: 300 }}},// 第二阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$category",count: { $sum: 1 }}},// 第三阶段:筛选出 count>=3 的文档{$match : {"count": { $gte: 3 }}}
])
// 1
{"_id": "Clothing","count": 3
}
3.4 SpringBoot 整合 MongoDB
// 输入文档实体
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体
@Data
public class AggregationResult {private String _id;private int count;
}// 执行聚合阶段
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $match 聚合阶段MatchOperation match1 = Aggregation.match(Criteria.where("price").gte(300));// $group 聚合阶段GroupOperation group = Aggregation.group("category").count().as("count");// $match 聚合阶段MatchOperation match2 = Aggregation.match(Criteria.where("count").gte(3));// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(match1,group,match2);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(_id=Clothing, count=3)}
}

4. $match-> $group-> $project-> $sort-> skip-> $limit

$match 根据条件筛选文档+ $group 根据单字段分组文档 + $project 重命名字段+ $sort 对文档按照唯一键排序

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "C", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "A", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "A", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "B", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "C", "category": "Clothing", "quantity": 12, "price": 700 }
])
4.1 $match

执行 $match 聚合阶段输出的文档为:

db.sales.aggregate([// $match 阶段:筛选出 price>100 的文档{$match : {"price": { $gt: 100 }}}
])
// 1
{"_id": 2,"product": "A","category": "Electronics","quantity": 5,"price": 200
}// 2
{"_id": 3,"product": "A","category": "Electronics","quantity": 5,"price": 300
}// 3
{"_id": 4,"product": "D","category": "Electronics","quantity": 10,"price": 500
}// 4
{"_id": 5,"product": "A","category": "Clothing","quantity": 8,"price": 500
}// 5
{"_id": 6,"product": "B","category": "Clothing","quantity": 12,"price": 200
}// 6
{"_id": 7,"product": "B","category": "Clothing","quantity": 8,"price": 600
}// 7
{"_id": 8,"product": "C","category": "Clothing","quantity": 12,"price": 700
}
4.2 $match-> $group

执行 $match + $group 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}},// $group阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}}
])
// 1
{"_id": "C","count": 1
}// 2
{"_id": "D","count": 1
}// 3
{"_id": "B","count": 2
}// 4
{"_id": "A","count": 3
}
4.3 $match-> $group-> $project

执行$match + $group + $project 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}},// $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:输出文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}}
])
// 1
{"count": 1,"product": "C"
}// 2
{"count": 1,"product": "D"
}// 3
{"count": 2,"product": "B"
}// 4
{"count": 3,"product": "A"
}
4.4 $match-> $group-> $project-> $sort

执行$match + $group + $project + $sort 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}}, // $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}},// $sort阶段:将聚合管道内的文档按照count字段降序排序{$sort : {count:-1}}
])
// 1
{"count": 3,"product": "A"
}// 2
{"count": 2,"product": "B"
}// 3
{"count": 1,"product": "C"
}// 4
{"count": 1,"product": "D"
}
4.5 $match-> $group-> $project-> $sort-> $skip
db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}}, // $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}},// $sort阶段:将聚合管道内的文档按照count字段降序排序{$sort : {count:-1}},// $skip阶段:跳过聚合管道的前2个文档并输出{$skip: 2}
])
// 1
{"count": 1,"product": "C"
}// 2
{"count": 1,"product": "D"
}
4.5 $match-> $group-> $project-> $sort-> $skip-> $limit

执行 $match + $group + $project + $sort + $limit 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}}, // $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}},// $sort阶段:将聚合管道内的文档按照count字段降序排序{$sort : {count:-1}},// $skip阶段:跳过聚合管道的前2个文档并输出{$skip: 2},// $limit阶段:仅输出聚合管道内的前1个文档{$limit: 1}
])
// 1
{"count": 1,"product": "C"
}
4.6 SpringBoot 整合 MongoDB
// 输入文档实体类
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体类
@Data
public class AggregationResult {private int count;private String product;
}// 执行聚合操作
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $match 聚合阶段MatchOperation match = Aggregation.match(Criteria.where("price").gt(100));// $group 聚合阶段GroupOperation group = Aggregation.group("product").count().as("count");// $project 聚合阶段ProjectionOperation project = Aggregation.project("count").andExclude("_id").and("$_id").as("product");// $sort聚合阶段SortOperation sort = Aggregation.sort(Sort.Direction.DESC, "count");// $skip 聚合阶段SkipOperation skip = Aggregation.skip(2);// $limit 聚合阶段LimitOperation limit = Aggregation.limit(1);// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(match,group,project,sort,skip,limit);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(count=1, product=C)}
}

5. $group-> $project

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "C", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "A", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "A", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "B", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "C", "category": "Clothing", "quantity": 12, "price": 700 }
])
5.1 $group 多字段分组聚合

$group 根据 category 和 product 字段分组后输出的文档为:

db.sales.aggregate([{// $group聚合阶段:将输入文档按照category和product字段分组$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}}
])
// 1
{"_id": {"category": "Clothing","product": "C"},"count": 1
}// 2
{"_id": {"category": "Clothing","product": "B"},"count": 2
}// 3
{"_id": {"category": "Clothing","product": "A"},"count": 1
}// 4
{"_id": {"category": "Electronics","product": "A"},"count": 2
}// 5
{"_id": {"category": "Electronics","product": "D"},"count": 1
}// 6
{"_id": {"category": "Electronics","product": "C"},"count": 1
}
5.2 $group-> $project

执行 $group + $project 聚合阶段后输出的文档为:

db.sales.aggregate([// $group聚合阶段:将输入文档按照category和product字段分组{$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}},// $project聚合阶段:发将_id.category重命名为category,将_id.product重命名为product,包含count字段,排除_id字段{$project: {category: "$_id.category",product: "$_id.product",count: 1,_id: 0}}
])
// 1
{"count": 1,"category": "Clothing","product": "C"
}// 2
{"count": 2,"category": "Clothing","product": "B"
}// 3
{"count": 1,"category": "Clothing","product": "A"
}// 4
{"count": 2,"category": "Electronics","product": "A"
}// 5
{"count": 1,"category": "Electronics","product": "D"
}// 6
{"count": 1,"category": "Electronics","product": "C"
}
5.3 $group-> $project-> $sort

执行 $group + $project + $sort 聚合阶段后输出的文档为:

db.sales.aggregate([// $group聚合阶段:将输入文档按照category和product字段分组{$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}},// $project聚合阶段:发将_id.category重命名为category,将_id.product重命名为product,包含count字段,排除_id字段{$project: {category: "$_id.category",product: "$_id.product",count: 1,_id: 0}},// $sort聚合阶段:将聚合管道内的文档按照count字段升序排序{$sort: {count:1}}
])
// 1
{"count": 1,"category": "Clothing","product": "C"
}// 2
{"count": 1,"category": "Clothing","product": "A"
}// 3
{"count": 1,"category": "Electronics","product": "D"
}// 4
{"count": 1,"category": "Electronics","product": "C"
}// 5
{"count": 2,"category": "Clothing","product": "B"
}// 6
{"count": 2,"category": "Electronics","product": "A"
}
5.4 $group-> $project-> $sort-> $limit

执行 $group + $project + $sort + $limit 聚合阶段后输出的文档为:

db.sales.aggregate([// $group聚合阶段:将输入文档按照category和product字段分组{$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}},// $project聚合阶段:发将_id.category重命名为category,将_id.product重命名为product,包含count字段,排除_id字段{$project: {category: "$_id.category",product: "$_id.product",count: 1,_id: 0}},// $sort聚合阶段:将聚合管道内的文档按照count字段升序排序{$sort: {count:1}},// $limit聚合阶段:仅输出聚合管道内的前2个文档{$limit:2}
])
// 1
{"count": 1,"category": "Clothing","product": "A"
}// 2
{"count": 1,"category": "Clothing","product": "C"
}
5.5 SpringBoot 整合 MongoDB
// 输入文档实体类
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体类
@Data
public class AggregationResult {private int count;private String product;private String category;
}// 执行聚合操作
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $group 聚合阶段GroupOperation group = Aggregation.group("category","product").count().as("count");// $project 聚合阶段ProjectionOperation project = Aggregation.project("count").andExclude("_id").and("$_id.category").as("category").and("$_id.product").as("product");// $sort聚合阶段SortOperation sort = Aggregation.sort(Sort.Direction.DESC, "count");// $limit 聚合阶段LimitOperation limit = Aggregation.limit(2);// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(group,project,sort,limit);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(count=2, product=A, category=Electronics)//AggregationResult(count=2, product=B, category=Clothing)}
}

相关文章:

MongoDB - 组合聚合阶段:$group、$match、$limit、$sort、$skip、$project、$count

文章目录 1. $group2. $group-> $project2.1 $group2.2 $group-> $project2.3 SpringBoot 整合 MongoDB 3. $match-> $group -> $match3.1 $match3.2 $match-> $group3.3 $match-> $group-> $match3.4 SpringBoot 整合 MongoDB 4. $match-> $group->…...

vue element-ui日期控件传参

前端&#xff1a;Vue element-ui <el-form-item label"过期时间" :rules"[ { required: true, message: 请选择过期时间, trigger: blur }]"><el-date-picker v-model"form.expireTime" type"date" format"yyyy-MM-dd&…...

MacOS安装SDKMan管理Java版本

文章目录 1 简介2 安装与卸载2.1 安装2.2 卸载 3 使用3.1 查看其他工具&#xff1a;支持 Ant, Maven 等3.2 查看Java版本3.3 安装Java&#xff0c;加上相关的版本3.4 设置Java版本(全局)3.5 只在当前窗口生效3.6 卸载1 默认环境无法卸载 4 jdk安装的位置5 与IDEA集成参考 1 简介…...

【网络安全的神秘世界】文件包含漏洞

&#x1f31d;博客主页&#xff1a;泥菩萨 &#x1f496;专栏&#xff1a;Linux探索之旅 | 网络安全的神秘世界 | 专接本 | 每天学会一个渗透测试工具 一、概述 文件包含&#xff1a;重复使用的函数写在文件里&#xff0c;需要使用某个函数时直接调用此文件&#xff0c;而无需再…...

并发编程--volatile

1.什么是volatile volatile是 轻 量 级 的 synchronized&#xff0c;它在多 处 理器开 发 中保 证 了共享 变 量的 “ 可 见 性 ” 。可 见 性的意思是当一个 线 程 修改一个共享变 量 时 &#xff0c;另外一个 线 程能 读 到 这 个修改的 值 。如果 volatile 变 量修 饰 符使用…...

记录unraid docker更新的域名

背景&#xff1a;级联 一、安装内容 unraid更新docker&#xff0c;之前一直失败&#xff0c;修改网络后可以进行安装。 二、查看域名 查看域名&#xff0c;发现是走github的&#xff0c;怪不得有一些docker无法正常更新 三、解决方法 更改代理&#xff0c;这里为unraid的…...

SpringCloud+Vue3多对多,多表联查

♥️作者&#xff1a;小宋1021 &#x1f935;‍♂️个人主页&#xff1a;小宋1021主页 ♥️坚持分析平时学习到的项目以及学习到的软件开发知识&#xff0c;和大家一起努力呀&#xff01;&#xff01;&#xff01; &#x1f388;&#x1f388;加油&#xff01; 加油&#xff01…...

麒麟系统信创改造

麒麟系统信创改造 一、查看操作系统架构下载相应的依赖,压缩包1、查看Linux系统架构、CPU(1)uname -m(2)lscpu(3)cat /proc/cpuinfo(4)arch(5)getconf LONG_BIT(6)dmidecode2、根据Linux系统架构、CPU的差异进行下载相关依赖,看第二项二、以下是根据本系统的aarc…...

【Android】ListView和RecyclerView知识总结

文章目录 ListView步骤适配器AdpterArrayAdapterSimpleAdapterBaseAdpter效率问题 RecyclerView具体实现不同布局形式的设置横向滚动瀑布流网格 点击事件 ListView ListView 是 Android 中的一种视图组件&#xff0c;用于显示可滚动的垂直列表。每个列表项都是一个视图对象&…...

泛域名绑定到wordpress网站二级目录

要将WordPress的泛域名绑定到二级目录&#xff0c;你需要在你的服务器上修改Apache或Nginx配置文件。以下是两种最常见的服务器配置的示例&#xff1a; Apache服务器 编辑你的虚拟主机配置文件&#xff0c;通常位于/etc/apache2/sites-available/目录下。 <VirtualHost *…...

8、从0搭建企业门户网站——网站部署

目录 正文 1、域名解析 2、云服务器端口授权 3、Mysql数据库初始化 4、上传网站软件包 5、Tomcat配置 6、运行Tomcat 7、停止Tomcat 8、部署后发现验证码无法使用 完毕! 正文 当云服务器租用、域名购买和软件开发都完成后,我们就可以开始网站部署上线,ICP备案会长…...

uniapp中出现图片过小会与盒子偏离

结论&#xff1a;在image的父盒子中加上display: flex&#xff0c;原因不清楚 出问题的代码和图片如下&#xff1a; <template><view style" background-color: greenyellow; height: 10rpx;width: 10rpx;"><image :src"imgSrc.seatnull" …...

MySQL练手 --- 1934. 确认率

题目链接&#xff1a;1934. 确认率 思路 由题可知&#xff0c;两个表&#xff0c;一个表为Signups注册表&#xff0c;另一个表为Confirmations信息确认表&#xff0c;表的关联关系为 一对一&#xff0c;且user_id作为两个表的连接条件&#xff08;匹配字段&#xff09;&#…...

【OpenCV C++20 学习笔记】扫描图片数据

扫描图片数据 应用情景图像数据扫描的难点颜色空间缩减&#xff08;color space reduction&#xff09;查询表 扫描算法计算查询表统计运算时长连续内存3种扫描方法C风格的扫描方法迭代器方法坐标方法LUT方法 算法效率对比结论 应用情景 图像数据扫描的难点 在上一篇文章《基…...

LeetCode:爬楼梯(C语言)

1、问题概述&#xff1a;每次可以爬 1 或 2 个台阶。有多少种不同的方法可以爬到楼顶 2、示例 示例 1&#xff1a; 输入&#xff1a;n 2 输出&#xff1a;2 解释&#xff1a;有两种方法可以爬到楼顶。 1. 1 阶 1 阶 2. 2 阶 示例 2&#xff1a; 输入&#xff1a;n 3 输出&a…...

银河麒麟(arm64)环境下通过docker安装postgis3,并实现数据整体迁移

银河麒麟(arm64)环境下通过docker安装postgis3,并实现数据整体迁移 硬件配置:麒麟9006C 系统环境:银河麒麟桌面版v10 sp1 数据库:postgresql11+postgis3.0 具体的步骤参考https://blog.csdn.net/qq_34817440/article/details/103914574 -----主要操作-----------------…...

C语言 | Leetcode C语言题解之第278题第一个错误的版本

题目&#xff1a; 题解&#xff1a; int firstBadVersion(int n) {int left 1, right n;while (left < right) { // 循环直至区间左右端点相同int mid left (right - left) / 2; // 防止计算时溢出if (isBadVersion(mid)) {right mid; // 答案在区间 [left, mid] 中…...

京东科技集团将在香港发行与港元1:1挂钩的加密货币稳定币

据京东科技集团旗下公司京东币链科技(香港)官网信息&#xff0c;京东稳定币是一种基于公链并与港元(HKD) 1:1挂钩的稳定币&#xff0c;将在公共区块链上发行&#xff0c;其储备由高度流动且可信的资产组成&#xff0c;这些资产安全存放于持牌金融机构的独立账户中&#xff0c;通…...

Vue 实现电子签名并生成签名图片

目录 前言项目结构代码实现 安装依赖创建签名画布组件生成签名图片 总结相关阅读 1. 前言 电子签名在现代Web应用中越来越普遍&#xff0c;例如合同签署、确认表单等。本文将介绍如何使用Vue.js实现一个简单的电子签名功能&#xff0c;并将签名生成图片。 2. 项目结构 项…...

Visual Studio 2022美化

说明&#xff1a; VS版本&#xff1a;Visual Studio Community 2022 背景美化 【扩展】【管理扩展】搜索“ClaudiaIDE”&#xff0c;【下载】&#xff0c;安装完扩展要重启VS 在wallhaven下载壁纸图片作为文本编辑器区域背景图片 【工具】【选项】搜索ClaudiaIDE&#xff…...

[CISCN2019 华东南赛区]Web11

进来先做信息收集&#xff0c;右上角显示当前ip&#xff0c;然后有api的调用地址和请求包的格式以及最重要的是最下面的smarty模版&#xff0c;一看到这个就得想到smarty模版注入 测试了一下两个api都无法访问 直接切到数据包看看能不能通过XFF来修改右上角ip 成功修改&#x…...

【图形图像-1】SDF

在图形图像处理中&#xff0c;SDF&#xff08;Signed Distance Field&#xff0c;带符号的距离场&#xff09;是一种表示图形轮廓和空间距离的数学结构。它通常用于计算机图形学、文本渲染、碰撞检测和物理模拟等领域。 SDF&#xff08;Signed Distance Field&#xff0c;带符号…...

苍穹外卖01

0. 配置maven (仅一次的操作 1.项目导入idea 2. 保证nginx服务器运行 &#xff08;nginx.exe要在非中文的目录下&#xff09; 开启服务&#xff1a; start nginx 查看任务进程是否存在&#xff1a; tasklist /fi "imagename eq nginx.exe" 关闭ngi…...

ElasticSearch(三)—文档字段参数设置以及元字段

一、 字段参数设置 analyzer&#xff1a; 指定分词器。elasticsearch 是一款支持全文检索的分布式存储系统&#xff0c;对于 text类型的字段&#xff0c;首先会使用分词器进行分词&#xff0c;然后将分词后的词根一个一个存储在倒排索引中&#xff0c;后续查询主要是针对词根…...

ARM功耗管理之压力测试和PM_DEBUG实验

安全之安全(security)博客目录导读 ARM功耗管理精讲与实战汇总参见&#xff1a;Arm功耗管理精讲与实战 思考&#xff1a;睡眠唤醒实验&#xff1f;压力测试&#xff1f;Suspend-to-Idle/RAM/Disk演示&#xff1f; 1、实验环境准备 2、软件代码准备 3、唤醒源 4、Suspend-…...

ESP8266用AT指令实现连接MQTT

1准备工作 硬件&#xff08;ESP8266&#xff09;连接电脑 硬件已经烧入了MQTT透传固件 2实现连接 2-1&#xff08;进入AT模式&#xff09; 打开串口助手发送如下指令 AT 2-2&#xff08;复位&#xff09; ATRST 2-3&#xff08;开启DHCP&#xff0c;自动获取IP&#x…...

人工智能与机器学习原理精解【5】

文章目录 最优化基础理论特征值&#xff08;Eigenvalue&#xff09;特征向量&#xff08;Eigenvector&#xff09;特征值和特征向量的重要性计算方法特征值一、特征值分解的定义二、特征值分解的算法三、特征值分解的例子 正定矩阵Hessian矩阵的特征值Hessian矩阵的含义Hessian…...

为什么用LeSS?

实现适应性 LeSS是一个产品开发的组织系统&#xff0c;旨在最大化一个组织的适应性。关于适应性&#xff08;或者敏捷性&#xff0c;也就是敏捷开发的初衷&#xff09;我们是指优化&#xff1a; 以相对低的成本改变方向的能力&#xff0c;主要是基于通过频繁交付产生的探索。从…...

力扣高频SQL 50题(基础版)第七题

文章目录 力扣高频SQL 50题&#xff08;基础版&#xff09;第七题1068. 产品销售分析 I题目说明思路分析实现过程准备数据&#xff1a;实现方式&#xff1a;结果截图:总结&#xff1a; 力扣高频SQL 50题&#xff08;基础版&#xff09;第七题 1068. 产品销售分析 I 题目说明 …...

【音视频】一篇文章区分直播与点播、推流与拉流

文章目录 前言直播和点播的概念及区别直播是什么点播是什么 直播和点播的区别举例说明推流与拉流推流是什么拉流是什么 推流与拉流的区别举例说明 总结 前言 在音视频领域&#xff0c;直播、点播、推流和拉流是常见的概念&#xff0c;每个术语都有其特定的含义和应用场景。了解…...