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

SpringBoot 整合 MongoDB 实现数据的增删改查!

一、介绍

在 MongoDB 中有三个比较重要的名词:数据库、集合、文档

  • 数据库(Database):和关系型数据库一样,每个数据库中有自己的用户权限,不同的项目组可以使用不同的数据库

  • 集合(Collection): 集合指的是文档组(类似于 Mysql 中的表的概念),里面可以存储许多文档

  • 文档(Document): 文档是 MongoDB 中最基本的数据单元,由键值对组成,类似于 JSON 格式,可以存储不同字段,字段的值可以包括其他文档、数组和文档数组

搞懂这三个名词,基本就可以上手了,今天我们以 SpringBoot 整合 MongoDB 为例,实现数据的增删改查

话不多说,直接开撸!

二、代码实践

2.1、创建 SpringBoot 工程,添加 MongoDB 依赖包

<!-- 引入springboot -->
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.0.RELEASE</version>
</parent><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

2.2、添加配置文件

application.properties文件中添加mongodb相关配置!

#配置数据库连接地址
spring.data.mongodb.uri=mongodb://userName:password@127.0.0.1:27017/dbName

相关参数说明:

  • userName:表示用户名,根据实际情况填写即可

  • password:表示用户密码,根据实际情况填写即可

  • dbName:表示数据库,可以自定义,初始化数据的时候,会自动创建

2.3、创建实体类

创建一个实体类Person,其中注解@Document(collection="persons")表示当前实体类对应的集合名称是persons,类似于关系型数据库中的表名称。

注解@Id表示当前字段,在集合结构中属于主键类型。

/*** 使用@Document注解指定集合名称*/
@Document(collection="persons")
public class Person implements Serializable {private static final long serialVersionUID = -3258839839160856613L;/*** 使用@Id注解指定MongoDB中的 _id 主键*/@Idprivate Long id;private String userName;private String passWord;private Integer age;private Date createTime;//...get/set@Overridepublic String toString() {return "Person{" +"id=" + id +", userName='" + userName + '\'' +", passWord='" + passWord + '\'' +", age=" + age +", createTime=" + createTime +'}';}
}

2.4、操作 MongoDB

Springboot 操作 MongoDB 有两种方式。

  • 第一种方式是采用 Springboot 官方推荐的 JPA 方式,这种操作方式,使用简单但是灵活性比较差。

  • 第二种方式是采用 Spring Data MongoDB 基于 MongoDB 官方 Java API 封装的 MongoTemplate 操作类对 MongoDB 进行操作,这种方式非常灵活,能满足绝大部分需求。

本文将采用第二种方式进行介绍!

2.5、插入文档

MongoTemplate提供了insert()方法,用于插入文档,示例代码如下:

  • 用于插入文档

没指定集合名称时,会取@Document注解中的集合名称
@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 插入文档* @throws Exception*/@Testpublic void insert() throws Exception {Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());mongoTemplate.insert(person);}
}
  • 自定义集合名称,插入文档

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 自定义集合,插入文档* @throws Exception*/@Testpublic void insertCustomCollection() throws Exception {Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());mongoTemplate.insert(person, "custom_person");}
}
  • 自定义集合,批量插入文档

如果采用批量插入文档,必须指定集合名称
@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 自定义集合,批量插入文档* @throws Exception*/@Testpublic void insertBatch() throws Exception {List<Person> personList = new ArrayList<>();Person person1 =new Person();person1.setId(10l);person1.setUserName("张三");person1.setPassWord("123456");person1.setCreateTime(new Date());personList.add(person1);Person person2 =new Person();person2.setId(11l);person2.setUserName("李四");person2.setPassWord("123456");person2.setCreateTime(new Date());personList.add(person2);mongoTemplate.insert(personList, "custom_person");}
}

2.6、存储文档

MongoTemplate提供了save()方法,用于存储文档。

在存储文档的时候会通过主键 ID 进行判断,如果存在就更新,否则就插入,示例代码如下:

  • 存储文档,如果没有插入,否则通过主键ID更新

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 存储文档,如果没有插入,否则更新* @throws Exception*/@Testpublic void save() throws Exception {Person person =new Person();person.setId(13l);person.setUserName("八八");person.setPassWord("123456");person.setAge(40);person.setCreateTime(new Date());mongoTemplate.save(person);}
}
  • 自定义集合,存储文档

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 自定义集合,存储文档* @throws Exception*/@Testpublic void saveCustomCollection() throws Exception {Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());mongoTemplate.save(person, "custom_person");}
}

2.7、更新文档

MongoTemplate提供了updateFirst()updateMulti()方法,用于更新文档,示例代码如下:

  • 更新文档,匹配查询到的文档数据中的第一条数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 更新文档,匹配查询到的文档数据中的第一条数据* @throws Exception*/@Testpublic void updateFirst() throws Exception {//更新对象Person person =new Person();person.setId(1l);person.setUserName("张三123");person.setPassWord("123456");person.setCreateTime(new Date());//更新条件Query query= new Query(Criteria.where("id").is(person.getId()));//更新值Update update= new Update().set("userName", person.getUserName()).set("passWord", person.getPassWord());//更新查询满足条件的文档数据(第一条)UpdateResult result =mongoTemplate.updateFirst(query,update, Person.class);if(result!=null){System.out.println("更新条数:" + result.getMatchedCount());}}
}
  • 更新文档,匹配查询到的文档数据中的所有数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 更新文档,匹配查询到的文档数据中的所有数据* @throws Exception*/@Testpublic void updateMany() throws Exception {//更新对象Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());//更新条件Query query= new Query(Criteria.where("id").is(person.getId()));//更新值Update update= new Update().set("userName", person.getUserName()).set("passWord", person.getPassWord());//更新查询满足条件的文档数据(全部)UpdateResult result = mongoTemplate.updateMulti(query, update, Person.class);if(result!=null){System.out.println("更新条数:" + result.getMatchedCount());}}
}

2.8、删除文档

MongoTemplate提供了remove()findAndRemove()findAllAndRemove()方法,用于删除文档,示例代码如下:

  • 删除符合条件的所有文档

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 更新文档,匹配查询到的文档数据中的所有数据* @throws Exception*/@Testpublic void updateMany() throws Exception {//更新对象Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());//更新条件Query query= new Query(Criteria.where("id").is(person.getId()));//更新值Update update= new Update().set("userName", person.getUserName()).set("passWord", person.getPassWord());//更新查询满足条件的文档数据(全部)UpdateResult result = mongoTemplate.updateMulti(query, update, Person.class);if(result!=null){System.out.println("更新条数:" + result.getMatchedCount());}}
}
  • 删除符合条件的单个文档,并返回删除的文档

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 删除符合条件的单个文档,并返回删除的文档* @throws Exception*/@Testpublic void findAndRemove() throws Exception {Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());Query query = new Query(Criteria.where("id").is(person.getId()));Person result = mongoTemplate.findAndRemove(query, Person.class);System.out.println("删除的文档数据:" + result.toString());}
}
  • 删除符合条件的所有文档,并返回删除的文档

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 删除符合条件的所有文档,并返回删除的文档* @throws Exception*/@Testpublic void findAllAndRemove() throws Exception {Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());Query query = new Query(Criteria.where("id").is(person.getId()));List<Person> result = mongoTemplate.findAllAndRemove(query, Person.class);System.out.println("删除的文档数据:" + result.toString());}
}

2.9、查询文档

MongoTemplate提供了非常多的文档查询方法,日常开发中用的最多的就是find()方法,示例代码如下:

  • 查询集合中的全部文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 查询集合中的全部文档数据* @throws Exception*/@Testpublic void findAll() throws Exception {List<Person> result = mongoTemplate.findAll(Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 查询集合中指定的ID文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 查询集合中指定的ID文档数据* @throws Exception*/@Testpublic void findById() {long id = 1l;Person result = mongoTemplate.findById(id, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据条件查询集合中符合条件的文档,返回第一条数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据条件查询集合中符合条件的文档,返回第一条数据*/@Testpublic void findOne() {String userName = "张三";Query query = new Query(Criteria.where("userName").is(userName));Person result = mongoTemplate.findOne(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据条件查询集合中符合条件的文档

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据条件查询集合中符合条件的文档*/@Testpublic void findByCondition() {String userName = "张三";Query query = new Query(Criteria.where("userName").is(userName));List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据【AND】关联多个查询条件,查询集合中的文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据【AND】关联多个查询条件,查询集合中的文档数据*/@Testpublic void findByAndCondition() {// 创建条件Criteria criteriaUserName = Criteria.where("userName").is("张三");Criteria criteriaPassWord = Criteria.where("passWord").is("123456");// 创建条件对象,将上面条件进行 AND 关联Criteria criteria = new Criteria().andOperator(criteriaUserName, criteriaPassWord);// 创建查询对象,然后将条件对象添加到其中Query query = new Query(criteria);List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据【OR】关联多个查询条件,查询集合中的文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据【OR】关联多个查询条件,查询集合中的文档数据*/@Testpublic void findByOrCondition() {// 创建条件Criteria criteriaUserName = Criteria.where("userName").is("张三");Criteria criteriaPassWord = Criteria.where("passWord").is("123456");// 创建条件对象,将上面条件进行 OR 关联Criteria criteria = new Criteria().orOperator(criteriaUserName, criteriaPassWord);// 创建查询对象,然后将条件对象添加到其中Query query = new Query(criteria);List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据【IN】关联多个查询条件,查询集合中的文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据【IN】关联多个查询条件,查询集合中的文档数据*/@Testpublic void findByInCondition() {// 设置查询条件参数List<Long> ids = Arrays.asList(1l, 10l, 11l);// 创建条件Criteria criteria = Criteria.where("id").in(ids);// 创建查询对象,然后将条件对象添加到其中Query query = new Query(criteria);List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据【逻辑运算符】查询集合中的文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据【逻辑运算符】查询集合中的文档数据*/@Testpublic void findByOperator() {// 设置查询条件参数int min = 20;int max = 35;Criteria criteria = Criteria.where("age").gt(min).lte(max);// 创建查询对象,然后将条件对象添加到其中Query query = new Query(criteria);List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据【正则表达式】查询集合中的文档数据

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据【正则表达式】查询集合中的文档数据*/@Testpublic void findByRegex() {// 设置查询条件参数String regex = "^张*";Criteria criteria = Criteria.where("userName").regex(regex);// 创建查询对象,然后将条件对象添加到其中Query query = new Query(criteria);List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据条件查询集合中符合条件的文档,获取其文档列表并排序

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据条件查询集合中符合条件的文档,获取其文档列表并排序*/@Testpublic void findByConditionAndSort() {String userName = "张三";Query query = new Query(Criteria.where("userName").is(userName)).with(Sort.by("age"));List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 根据单个条件查询集合中的文档数据,并按指定字段进行排序与限制指定数目

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据单个条件查询集合中的文档数据,并按指定字段进行排序与限制指定数目*/@Testpublic void findByConditionAndSortLimit() {String userName = "张三";//从第一行开始,查询2条数据返回Query query = new Query(Criteria.where("userName").is(userName)).with(Sort.by("createTime")).limit(2).skip(1);List<Person> result = mongoTemplate.find(query, Person.class);System.out.println("查询结果:" + result.toString());}
}
  • 统计集合中符合【查询条件】的文档【数量】

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 统计集合中符合【查询条件】的文档【数量】*/@Testpublic void countNumber() {// 设置查询条件参数String regex = "^张*";Criteria criteria = Criteria.where("userName").regex(regex);// 创建查询对象,然后将条件对象添加到其中Query query = new Query(criteria);long count = mongoTemplate.count(query, Person.class);System.out.println("统计结果:" + count);}
}

3.0、索引管理

索引在所有的数据库中,暂居的位置非常重要,例如当你检索一张上百万的数据表的时候,如果没走索引,查询效率会极其缓慢,对于 MongoDB 来说,同样如此。

示例如下:

  • 创建升序索引

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 创建升序索引*/@Testpublic void createAscendingIndex() {// 设置字段名称String field = "userName";// 创建索引mongoTemplate.getCollection("persons").createIndex(Indexes.ascending(field));}
}
  • 移除索引

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 根据索引名称移除索引*/@Testpublic void removeIndex() {// 设置字段名称String field = "userName";// 删除索引mongoTemplate.getCollection("persons").dropIndex(field);}
}
  • 查询集合中所有的索引

@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;/*** 查询集合中所有的索引*/@Testpublic void getIndexAll() {// 获取集合中所有列表ListIndexesIterable<Document> indexList = mongoTemplate.getCollection("persons").listIndexes();// 获取集合中全部索引信息for (Document document : indexList) {System.out.println("索引列表:" + document);}}
}
  • 我们还可以通过在实体类上加注解方式来创建索引

/*** 使用@Document注解指定集合名称*/
@Document(collection="persons")
public class Person implements Serializable {private static final long serialVersionUID = -3258839839160856613L;/*** 使用@Id注解指定MongoDB中的 _id 主键*/@Idprivate Long id;private String userName;private String passWord;private Integer age;/*** 创建一个5秒之后文档自动删除的索引*/@Indexed(expireAfterSeconds=5)private Date createTime;//...get/set@Overridepublic String toString() {return "Person{" +"id=" + id +", userName='" + userName + '\'' +", passWord='" + passWord + '\'' +", age=" + age +", createTime=" + createTime +'}';}
}

3.1、引入 MongoDB 中的事务

单节点 mongodb 不支持事务,需要搭建 MongoDB 复制集。
/*** 配置事务管理器**/
@Configuration
public class TransactionConfig {@BeanMongoTransactionManager transactionManager(MongoDatabaseFactory dbFactory) {return new MongoTransactionManager(dbFactory);}}

事务服务测试!

@Service
public class TransactionExample {@Autowiredprivate MongoTemplate mongoTemplate;@Transactional(rollbackFor = Exception.class)public Object transactionTest(){Person person =new Person();person.setId(1l);person.setUserName("张三");person.setPassWord("123456");person.setCreateTime(new Date());Person newPerson = mongoTemplate.insert(person);// 测试抛出异常,观察数据是否进行回滚if(1 == 1){throw new RuntimeException("异常");}return newPerson;}
}

三、小结

本文主要围绕 SpringBoot 整合 MongoDB 实现数据的增删改查操作进行基本介绍,如果有描述不对的,还原网友留言指出!

在实际的业务场景中,可能还需要用到聚合函数等高级查询,大家如果有这种需求,可以访问如下地址获取更加详细的 api 文档介绍:MongoDB 文档查询 api 介绍

相关文章:

SpringBoot 整合 MongoDB 实现数据的增删改查!

一、介绍在 MongoDB 中有三个比较重要的名词&#xff1a;数据库、集合、文档&#xff01;数据库&#xff08;Database&#xff09;&#xff1a;和关系型数据库一样&#xff0c;每个数据库中有自己的用户权限&#xff0c;不同的项目组可以使用不同的数据库集合&#xff08;Colle…...

VUE前端常问面试题

文章目录一、VUE前端常问面试题二、文档下载地址一、VUE前端常问面试题 1、MVC和MVVM 区别 MVC&#xff1a;MVC全名是 Model View Controller&#xff0c;即模型-视图-控制器的缩写&#xff0c;一种软件设计典范。 Model(模型)&#xff1a;是用于处理应用程序数据逻辑部分。通…...

c++中map/unordered_map的不同遍历方式以及结构化绑定

文章目录方式一&#xff1a;值传递遍历方式二&#xff1a;引用传递遍历方式三&#xff1a;使用迭代器遍历方式四&#xff1a;结构化绑定(c17特性)结构化绑定示例&#xff08;1&#xff09;元组tuple结构化绑定&#xff08;2&#xff09;结构体结构化绑定&#xff08;3&#xff…...

Kafka系列之:Kraft模式

Kafka系列之:Kraft模式 一、Kraft架构二、Kafka的Kraft集群部署三、初始化集群数据目录四、创建KafkaTopic五、查看Kafka Topic六、创建生产者七、创建消费者一、Kraft架构 Kafka元数据存储在zookeeper中,运行时动态选举controller,由controller进行Kafka集群管理。Kraft模式…...

动态规划:leetcode 139.单词拆分、多重背包问题

leetcode 139.单词拆分leetcode 139.单词拆分给定一个非空字符串 s 和一个包含非空单词的列表 wordDict&#xff0c;判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词。说明&#xff1a;拆分时可以重复使用字典中的单词。你可以假设字典中没有重复的单词。示例 1&…...

Stable Diffusion原理详解

Stable Diffusion原理详解 最近AI图像生成异常火爆&#xff0c;听说鹅厂都开始用AI图像生成做前期设定了&#xff0c;小厂更是直接用AI替代了原画师的岗位。这一张张丰富细腻、风格各异、以假乱真的AI生成图像&#xff0c;背后离不开Stable Diffusion算法。 Stable Diffusion…...

webpack高级配置

摇树&#xff08;tree shaking&#xff09; 我主要是想说摇树失败的原因&#xff08;tree shaking 失败的原因&#xff09;&#xff0c;先讲下摇树本身效果 什么是摇树&#xff1f; 举个例子 首先 webpack.config.js配置 const webpack require("webpack");/**…...

jQuery 事件

jQuery 事件 Date: February 28, 2023 Sum: jQuery事件注册、处理、对象 目标&#xff1a; 能够说出4种常见的注册事件 能够说出 on 绑定事件的优势 能够说出 jQuery 事件委派的优点以及方式 能够说出绑定事件与解绑事件 jQuery 事件注册 单个时间注册 语法&#xff1a;…...

【批处理脚本】-2.3-解析地址命令arp

"><--点击返回「批处理BAT从入门到精通」总目录--> 共2页精讲(列举了所有arp的用法,图文并茂,通俗易懂) 目录 1 arp命令解析 1.1 询问当前协议数据,显示当前 ARP 项...

改进 YOLO V5 的密集行人检测算法研究(论文研读)——目标检测

改进 YOLO V5 的密集行人检测算法研究&#xff08;2021.08&#xff09;摘 要&#xff1a;1 YOLO V52 SENet 通道注意力机制3 改进的 YOLO V5 模型3.1 训练数据处理改进3.2 YOLO V5 网络改进3.3 损失函数改进3.3.1 使用 CIoU3.3.2 非极大值抑制改进4 研究方案与结果分析4.1 实验…...

Python - Opencv应用实例之CT图像检测边缘和内部缺陷

Python - Opencv应用实例之CT图像检测边缘和内部缺陷 将传统图像处理处理算法应用于CT图像的边缘检测和缺陷检测,想要实现效果如下: 关于图像处理算法,主要涉及的有:灰度、阈值化、边缘或角点等特征提取、灰度相似度变换,主要偏向于一些2D的几何变换、涉及图像矩阵的一些统…...

管理逻辑备数据库(Logical Standby Database)

1. SQL Apply架构概述 SQL Apply使用一组后台进程来应用来自主数据库的更改到逻辑备数据库。 在日志挖掘和应用处理中涉及到的不同的进程和它们的功能如下&#xff1a; 在日志挖掘过程中&#xff1a; 1&#xff09;READER进程从归档redo日志文件或备redo日志文件中读取redo记…...

【C++】构造函数(初始化列表)、explicit、 Static成员、友元、内部类、匿名对象

构造函数&#xff08;初始化列表&#xff09;前提构造函数体赋值初始化列表explicit关键字static成员概念特性&#xff08;重要&#xff09;有元友元函数友元类内部类匿名对象构造函数&#xff08;初始化列表&#xff09; 前提 前面 六个默认成员对象中我们已经学过什么是构造…...

(六十)再来看看几个最常见和最基本的索引使用规则

今天我们来讲一下最常见和最基本的几个索引使用规则&#xff0c;也就是说&#xff0c;当我们建立好一个联合索引之后&#xff0c;我们的SQL语句要怎么写&#xff0c;才能让他的查询使用到我们建立好的索引呢&#xff1f; 下面就一起来看看&#xff0c;还是用之前的例子来说明。…...

机器学习与目标检测作业(数组相加:形状需要满足哪些条件)

机器学习与目标检测&#xff08;数组相加:形状需要满足哪些条件&#xff09;机器学习与目标检测&#xff08;数组相加:形状需要满足哪些条件&#xff09;一、形状相同1.1、形状相同示例程序二、符合广播机制2.1、符合广播机制的描述2.2、符合广播机制的示例程序机器学习与目标检…...

CentOS救援模式(Rescue Mode)及紧急模式(Emergency Mode)

当CentOS操作系统崩溃&#xff0c;无法正常启动时&#xff0c;可以通过救援模式或者紧急模式进行系统登录。启动CentOS, 当出现下面界面时&#xff0c;按e进入编辑界面。在编辑界面里&#xff0c;加入参数&#xff1a;systemd.unitrescue.target &#xff0c;然后Ctrl-X启动进入…...

从面试官角度告诉你高级性能测试工程师面试必问的十大问题

目录 1、介绍下最近做过的项目&#xff0c;背景、预期指标、系统架构、场景设计及遇到的性能问题&#xff0c;定位分析及优化&#xff1b; 2、项目处于什么阶段适合性能测试介入&#xff0c;原因是什么&#xff1f; 3、性能测试场景设计要考虑哪些因素&#xff1f; 4、对于一…...

通过知识库深度了解用户的心理

自助服务知识库的价值是毋庸置疑的&#xff0c;如果执行得当&#xff0c;可以帮助减少客户服务团队的工作量&#xff0c;仅仅编写内容和发布是不够的&#xff0c;需要知道知识库对客户来说是否有用&#xff0c;需要了解客户获得的反馈&#xff0c;如果你正确的使用知识库软件&a…...

HiveSQL一天一个小技巧:如何将分组内数据填充完整?

0 需求1 需求分析需求分析&#xff1a;需求中需要求出分组中按成绩排名取倒数第二的值作为新字段&#xff0c;且分组内没有倒数第二条的时候取当前值。如果本题只是求分组内排序后倒数第二&#xff0c;则很简单&#xff0c;使用row_number()函数即可求出&#xff0c;但是本题问…...

【亲测可用】BEV Fusion (MIT) 环境配置

CUDA环境 首先我们需要打上对应版本的显卡驱动&#xff1a; 接下来下载CUDA包和CUDNN包&#xff1a; wget https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run sudo sh cuda_11.6.2_510.47.03_linux.runwget htt…...

Vue记事本应用实现教程

文章目录 1. 项目介绍2. 开发环境准备3. 设计应用界面4. 创建Vue实例和数据模型5. 实现记事本功能5.1 添加新记事项5.2 删除记事项5.3 清空所有记事 6. 添加样式7. 功能扩展&#xff1a;显示创建时间8. 功能扩展&#xff1a;记事项搜索9. 完整代码10. Vue知识点解析10.1 数据绑…...

从深圳崛起的“机器之眼”:赴港乐动机器人的万亿赛道赶考路

进入2025年以来&#xff0c;尽管围绕人形机器人、具身智能等机器人赛道的质疑声不断&#xff0c;但全球市场热度依然高涨&#xff0c;入局者持续增加。 以国内市场为例&#xff0c;天眼查专业版数据显示&#xff0c;截至5月底&#xff0c;我国现存在业、存续状态的机器人相关企…...

C++ 基础特性深度解析

目录 引言 一、命名空间&#xff08;namespace&#xff09; C 中的命名空间​ 与 C 语言的对比​ 二、缺省参数​ C 中的缺省参数​ 与 C 语言的对比​ 三、引用&#xff08;reference&#xff09;​ C 中的引用​ 与 C 语言的对比​ 四、inline&#xff08;内联函数…...

JDK 17 新特性

#JDK 17 新特性 /**************** 文本块 *****************/ python/scala中早就支持&#xff0c;不稀奇 String json “”" { “name”: “Java”, “version”: 17 } “”"; /**************** Switch 语句 -> 表达式 *****************/ 挺好的&#xff…...

NXP S32K146 T-Box 携手 SD NAND(贴片式TF卡):驱动汽车智能革新的黄金组合

在汽车智能化的汹涌浪潮中&#xff0c;车辆不再仅仅是传统的交通工具&#xff0c;而是逐步演变为高度智能的移动终端。这一转变的核心支撑&#xff0c;来自于车内关键技术的深度融合与协同创新。车载远程信息处理盒&#xff08;T-Box&#xff09;方案&#xff1a;NXP S32K146 与…...

OpenGL-什么是软OpenGL/软渲染/软光栅?

‌软OpenGL&#xff08;Software OpenGL&#xff09;‌或者软渲染指完全通过CPU模拟实现的OpenGL渲染方式&#xff08;包括几何处理、光栅化、着色等&#xff09;&#xff0c;不依赖GPU硬件加速。这种模式通常性能较低&#xff0c;但兼容性极强&#xff0c;常用于不支持硬件加速…...

理想汽车5月交付40856辆,同比增长16.7%

6月1日&#xff0c;理想汽车官方宣布&#xff0c;5月交付新车40856辆&#xff0c;同比增长16.7%。截至2025年5月31日&#xff0c;理想汽车历史累计交付量为1301531辆。 官方表示&#xff0c;理想L系列智能焕新版在5月正式发布&#xff0c;全系产品力有显著的提升&#xff0c;每…...

Linux--vsFTP配置篇

一、vsFTP 简介 vsftpd&#xff08;Very Secure FTP Daemon&#xff09;是 Linux 下常用的 FTP 服务程序&#xff0c;具有安全性高、效率高和稳定性好等特点。支持匿名访问、本地用户登录、虚拟用户等多种认证方式&#xff0c;并可灵活控制权限。 二、安装与启动 1. 检查是否已…...

Razor编程中@Helper的用法大全

文章目录 第一章&#xff1a;Helper基础概念1.1 Helper的定义与作用1.2 Helper的基本语法结构1.3 Helper与HtmlHelper的区别 第二章&#xff1a;基础Helper用法2.1 无参数Helper2.2 带简单参数的Helper2.3 带默认值的参数2.4 使用模型作为参数 第三章&#xff1a;高级Helper用法…...

Jmeter(四) - 如何在jmeter中创建网络测试计划

1.简介 如何创建基本的 测试计划来测试网站。您将创建五个用户&#xff0c;这些用户将请求发送到JMeter网站上的两个页面。另外&#xff0c;您将告诉用户两次运行测试。 因此&#xff0c;请求总数为&#xff08;5个用户&#xff09;x&#xff08;2个请求&#xff09;x&#xff…...