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

十七,Spring Boot 整合 MyBatis 的详细步骤(两种方式)

十七,Spring Boot 整合 MyBatis 的详细步骤(两种方式)

文章目录

  • 十七,Spring Boot 整合 MyBatis 的详细步骤(两种方式)
  • 1. Spring Boot 配置 MyBatis 的详细步骤
  • 2. 最后:


MyBatis 的官方文档:https://mybatis.p2hp.com/

在这里插入图片描述

关于 MyBatis 的学习的详细内容,大家可以移步至:✏️✏️✏️ MyBatis_ChinaRainbowSea的博客-CSDN博客 。

1. Spring Boot 配置 MyBatis 的详细步骤

  1. 首先,我们创建相关测试的数据库,数据表。如下:

在这里插入图片描述


CREATE DATABASE `springboot_mybatis`
USE `springboot_mybatis`CREATE TABLE `monster` (
`id` int not null auto_increment,
`age` int not null,
`birthday` DATE DEFAULT NULL,
`email` VARCHAR(255) DEFAULT NULL,
`gender` CHAR(1) DEFAULT null,
`name` VARCHAR(255) DEFAULT NULL,
`salary` DOUBLE not NULL,
PRIMARY KEY(`id`)
)SELECT * from monsterINSERT INTO  `monster` (`id`,`age` ,`birthday`,`email`,`gender`,`name`,`salary`) 
VALUES (1,20,'2000-10-10','nmw@sohu.com','男','牛魔王',9000.99)
INSERT INTO  `monster` (`id`,`age` ,`birthday`,`email`,`gender`,`name`,`salary`)
VALUES (2,10,'2000-12-12','bgj@sohu.com','女','白骨精',9999.99)
  1. 导入相关的 jar 依赖。这里我们使用 Druid 数据库连接池,同时我们还需要导入 mybatis.spring.boot 的。

在这里插入图片描述

<!--        引入 mybatis starter--><!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter --><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.2.2</version></dependency>

引入 Druid 数据库的 jar 依赖。

在这里插入图片描述

<!--        引入 druid 依赖--><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.17</version></dependency>

所有的 pom.xml 文件当中的 jar 依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.rainbowsea</groupId><artifactId>springboot_mybaits</artifactId><version>1.0-SNAPSHOT</version><!--    导入SpringBoot 父工程-规定写法--><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.3</version></parent><!--    导入web项目场景启动器:会自动导入和web开发相关的jar包所有依赖【库/jar】--><!--    后面还会在说明spring-boot-starter-web 到底引入哪些相关依赖--><dependencies>
<!--        引入 web starter 依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--        引入 mybatis starter--><!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter --><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.2.2</version></dependency><!--        引入 mysql 驱动: 这里老师使用版本仲裁 8.0.26--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!--        引入配置处理器--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId></dependency><!--引入lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><!--        引入 test stater --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency><!--        引入 druid 依赖--><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.17</version></dependency></dependencies></project>
  1. 编写对应 数据表的在Java当中对应的 Bean 对象。

在这里插入图片描述

特殊说明:

这里使用 @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") 注解。来设置数据表当中的时间赋值到该 Bean 对象上的时间属性的一个时间格式。

  • pattern = "yyyy-MM-dd" 是设置时间显示的格式样式
  • timezone = "GMT+8" 是设置时区差。这里我们中国是东半球,时差为 + 8 个小时。

需要注意的是:这个注解只对前端显示,有效果,后端,控制台显示无效。

在这里插入图片描述

  1. 将Spring Boot 默认的 HikariCP 数据库连接池,切换为我们想要的 Druid 数据库连接池。

这里我们通过配置类的方式,进行切换。

在这里插入图片描述

package com.rainbowsea.springboot.mybatis.config;import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import javax.sql.DataSource;@Configuration
public class DruidDataSourceConfig {@ConfigurationProperties(value = "spring.datasource")  // 读取 类路径下的application.yaml// 的信息,并为下面的 对应的 setXX 进行赋值操作@Beanpublic DataSource dataSource() {DruidDataSource druidDataSource = new DruidDataSource();return druidDataSource;}}

在 resource 类路径下创建一个,名为 applicaiton.yaml 文件,配置编写,相关对于,Druid 数据库连接池的信息。如下:

在这里插入图片描述

server:port: 9090  # 注意:使用空格spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverusername: rootpassword: MySQL123url: jdbc:mysql://localhost:3306/springboot_mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8

在这里插入图片描述

  1. 编写项目的场景启动器

在这里插入图片描述

package com.rainbowsea.springboot.mybatis;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;@SpringBootApplication
public class Application {public static void main(String[] args) {ConfigurableApplicationContext ioc = SpringApplication.run(Application.class, args);}}
  1. 运行测试,我们是否成功切换为了,我们想要的 Duird 数据连接池,因为在 Spring Boot 当中测试的话,必须要编写好对应的项目启动器,不然,是无法测试的,会报错。

在这里插入图片描述

在这里插入图片描述

package com.rainbowsea.springboot.mybatis;import com.rainbowsea.springboot.mybatis.bean.Monster;
import com.rainbowsea.springboot.mybatis.mapper.MonsterMapper;
import com.rainbowsea.springboot.mybatis.service.MonsterService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;import javax.annotation.Resource;@SpringBootTest(classes = Application.class)  // 与 main 不同的需要指明 测试的是哪个Class类
public class ApplicationTest {@Resourceprivate JdbcTemplate jdbcTemplate;@Testpublic void t1() {// 输出看看当前的数据源是什么System.out.println(jdbcTemplate.getDataSource().getClass());}}
  1. 创建一个mapper/dao 的包,在该包下创建一个名为 MonsterMapper 的接口,通过代理类的方式,在该接口下,编写我们要执行业务的 SQL 语句的方法。

在这里插入图片描述

package com.rainbowsea.springboot.mybatis.mapper;import com.rainbowsea.springboot.mybatis.bean.Monster;
import org.apache.ibatis.annotations.Mapper;/*** 在Mapper接口使用 @Mapper 就会扫描,并将Mapper接口对象注入*/
@Mapper // 包扫描,加上了这个注解的话,那么
public interface MonsterMapper {// 方法 根据id 返回 Monster 对象public Monster getMonsterById(Integer id);}

特别说明:

这里我们在该 接口类当中,使用了 @Mapper 注解。该注解的作用就是,让Spring Boot 加载的时候,会扫描这个类。从而找到这个类。这样我们就不需要额外的配置,包扫描了

  1. 在相应的对应的包,下创建对应的包,创建对应 SQl 语句的xml 文件。如下

在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.rainbowsea.springboot.mybatis.mapper.MonsterMapper">
<!--1. 扫描所有的dao接口的实现,加入到ioc容器中2. 这里dao接口,就是mapper接口
--><!--    配置 getMonsterById--><select id="getMonsterById" resultType="com.rainbowsea.springboot.mybatis.bean.Monster">select * from monster where id = #{id}</select>
<!--  elect * from `monster` where id = #{id} 注意: 不是单引号处理 -->
</mapper>

同时需要在,application.yaml 文件当中配置,Mybatis 的包扫描路径:如下;

在这里插入图片描述

mybatis:# 指定要扫描的 Xxxmapper.xmlmapper-locations: classpath:mapper/*.xml
server:port: 9090  # 注意:使用空格spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverusername: rootpassword: MySQL123url: jdbc:mysql://localhost:3306/springboot_mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8mybatis:# 指定要扫描的 Xxxmapper.xmlmapper-locations: classpath:mapper/*.xml# 通过config-location 可以指定mybatis-config.xml 可以以传统的方式来配置mybatis
#  config-location:
# 我们可以直接在 application.yaml 进行配置
# 举例说明1,比如配置原来的 typeAliases# 还有很多配置,等我们用到再说
#  type-aliases-package: com.rainbowsea.springboot.mybatis.bean
#  configuration:
#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#    map-underscore-to-camel-case: true# 老师说明: 配置mybatis的两种方式的选择: 如果配置比较简单,就直接在application.yaml配置
# 如配置内部比较多,可以考虑单独的做一个mybatis-config.xml

运行测试:

在这里插入图片描述

package com.rainbowsea.springboot.mybatis;import com.rainbowsea.springboot.mybatis.bean.Monster;
import com.rainbowsea.springboot.mybatis.mapper.MonsterMapper;
import com.rainbowsea.springboot.mybatis.service.MonsterService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;import javax.annotation.Resource;@SpringBootTest(classes = Application.class)  // 与 main 不同的需要指明 测试的是哪个Class类
public class ApplicationTest {@Resourceprivate MonsterMapper monsterMapper;@Testpublic void getMonsterById() {Monster monsterById = monsterMapper.getMonsterById(1);System.out.println(monsterById);}}

在这里插入图片描述

  1. 编写对应的 Severl 业务处理

首先,编写其接口:
在这里插入图片描述

package com.rainbowsea.springboot.mybatis.service;import com.rainbowsea.springboot.mybatis.bean.Monster;public interface MonsterService {// 根据id 返回 Monster 对象public Monster getMonsterById(Integer id);
}

在编写其接口的实现类,

在这里插入图片描述

package com.rainbowsea.springboot.mybatis.service.impl;import com.rainbowsea.springboot.mybatis.bean.Monster;
import com.rainbowsea.springboot.mybatis.mapper.MonsterMapper;
import com.rainbowsea.springboot.mybatis.service.MonsterService;
import org.springframework.stereotype.Service;import javax.annotation.Resource;@Service
public class MonsterServiceImpl implements MonsterService {// 装配MonsterMapper@Resourceprivate MonsterMapper monsterMapper;@Overridepublic Monster getMonsterById(Integer id) {return monsterMapper.getMonsterById(id);}
}

运行测试:

在这里插入图片描述

package com.rainbowsea.springboot.mybatis;import com.rainbowsea.springboot.mybatis.bean.Monster;
import com.rainbowsea.springboot.mybatis.mapper.MonsterMapper;
import com.rainbowsea.springboot.mybatis.service.MonsterService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;import javax.annotation.Resource;@SpringBootTest(classes = Application.class)  // 与 main 不同的需要指明 测试的是哪个Class类
public class ApplicationTest {// 装配到MonsterService@Resourceprivate MonsterService monsterService;// 测试 MonsterService@Testpublic void getMonsterById2() {Monster monster = monsterService.getMonsterById(2);System.out.println(monster);}}

在这里插入图片描述

  1. 编写对应的 Controller 控制器,在前端处理显示。

在这里插入图片描述

package com.rainbowsea.springboot.mybatis.controller;import com.rainbowsea.springboot.mybatis.bean.Monster;
import com.rainbowsea.springboot.mybatis.service.MonsterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import javax.annotation.Resource;@Controller
public class MonsterController {// 装配MonsterService@Resourceprivate MonsterService monsterService;@ResponseBody@GetMapping("/monster")public Monster getMonsterById( @RequestParam(value = "id") Integer id) {return monsterService.getMonsterById(id);}
}

运行测试:注意:我们这里配置的端口是9090,并不是8080。

在这里插入图片描述

2. 最后:

“在这个最后的篇章中,我要表达我对每一位读者的感激之情。你们的关注和回复是我创作的动力源泉,我从你们身上吸取了无尽的灵感与勇气。我会将你们的鼓励留在心底,继续在其他的领域奋斗。感谢你们,我们总会在某个时刻再次相遇。”

在这里插入图片描述

相关文章:

十七,Spring Boot 整合 MyBatis 的详细步骤(两种方式)

十七&#xff0c;Spring Boot 整合 MyBatis 的详细步骤(两种方式) 文章目录 十七&#xff0c;Spring Boot 整合 MyBatis 的详细步骤(两种方式)1. Spring Boot 配置 MyBatis 的详细步骤2. 最后&#xff1a; MyBatis 的官方文档&#xff1a;https://mybatis.p2hp.com/ 关于 MyBa…...

DNS协议解析

DNS协议解析 什么是DNS协议 IP地址&#xff1a;一长串唯一标识网络上的计算机的数字 域名&#xff1a;一串由点分割的字符串名字 网址包含了域名 DNS&#xff1a;域名解析协议 IP>域名 --反向解析 域名>IP --正向解析 域名 由ICANN管理&#xff0c;有级别&#xf…...

每日一题——第一百零八题

题目&#xff1a; 写几个函数&#xff0c; ①输入10个职工的姓名和职工号 ②按照职工号由小到大排列&#xff0c; 姓名顺序也随之调整 ③要求输入一个职工号&#xff0c; 用折半查找找出该职工的姓名 #include<stdio.h> #include<string.h> #define MAX_EMPOLYEES…...

使用Python免费将pdf转为docx

刚刚想将pdf转换为docx文档时&#xff0c;居然要收费 还好我学过编程&#xff0c;这不得露两手 将pdf 转换为 docx 文档 的操作步骤 我这里使用的是Python语言 &#xff08;1&#xff09;在终端上安装 pdf2docx 是一个 Python 库&#xff0c;它可以将 PDF 文件转换为 Word (…...

树莓派4B+UBUNTU20.04+静态ip+ssh配置

树莓派4B+UBUNTU20.04+静态ip+ssh配置 1.烧录Ubuntu镜像1.1选择pi 4b1.2选择ubuntu server (服务器版,无桌面)20.041.3选择sd卡1.4 点击右下角 NEXT ,编辑设置,输入密码,wifi选CN, 开启ssh1.5 烧录,依次点击“是”,等待完成2 烧录完成后装入树莓派,上电,等待系统完成配…...

C#实现指南:将文件夹与exe合并为一个exe

在软件开发过程中&#xff0c;有时需要将多个文件&#xff08;如资源文件、配置文件等&#xff09;与可执行文件&#xff08;exe&#xff09;打包在一起&#xff0c;以便于分发和部署。在C#中&#xff0c;我们可以利用ILMerge或Costura.Fody等工具来实现这一目标。本文将介绍如…...

linux信号 | 学习信号三步走 | 全解析信号的产生方式

前言&#xff1a;本节内容是信号&#xff0c; 主要讲解的是信号的产生。信号的产生是我们学习信号的第二个阶段。 我们已经学习过第一个阶段——信号的概念与预备知识&#xff08;没有学过的友友可以查看我的前一篇文章&#xff09;。 以及我们还没有学习信号的第三个阶段——信…...

C++ 刷题 使用到的一些有用的容器和函数

优先队列 c优先队列priority_queue&#xff08;自定义比较函数&#xff09;_c优先队列自定义比较-CSDN博客 373. 查找和最小的 K 对数字 - 力扣&#xff08;LeetCode&#xff09; 官方题解&#xff1a; class Solution { public:vector<vector<int>> kSmallestP…...

【Kubernetes】常见面试题汇总(三十四)

目录 86. K8s 每个 Pod 中有一个特殊的 Pause 容器能否去除&#xff0c;简述原因。 特别说明&#xff1a; 题目 1-68 属于【Kubernetes】的常规概念题&#xff0c;即 “ 汇总&#xff08;一&#xff09;~&#xff08;二十二&#xff09;” 。 题目 69-113 属于【Kuberne…...

C++标准库双向链表 list 中的insert函数实现。

CPrimer中文版&#xff08;第五版&#xff09;&#xff1a; //运行时错误&#xff1a;迭代器表示要拷贝的范围&#xff0c;不能指向与目的位置相同的容器 slist.insert(slist.begin(),slist.begin(),slist.end()); 如果我们传递给insert一对迭代器&#xff0c;它们不能…...

华为机考练习(golang)

输入 第一行输入一个正整数N&#xff0c;表示整数个数。&#xff08;0<N<100000&#xff09; 第二行输入N个整数&#xff0c;整数的取值范围为[-100,100]。 第三行输入一个正整数M&#xff0c;M代表窗口的大小&#xff0c;M<100000&#xff0c;且M<N。 输出 窗口…...

51单片机快速入门之按键应用拓展

51单片机快速入门之按键应用拓展 LED的点动控制: 循环检测,当key 为0 时 led 亮 反之为熄灭 while(1){ if(key!1) { led0; }else { led1; } } LED的锁定控制: 当按钮按下,led取反值 while(1) { if(key!1) { led!led; } } LED的4路抢答控制: bz默认为0 !bz 取反值,循环启动…...

数据库 - MySQL的事务

目录 前言 一、事务的特性 &#xff08;一&#xff09;原子性 &#xff08;二&#xff09;一致性 &#xff08;三&#xff09;隔离性 &#xff08;四&#xff09;持久性 二、事务的控制语句 三、事务隔离级别 &#xff08;一&#xff09;读未提交 &#xff08;二&…...

【Python机器学习】NLP信息提取——提取人物/事物关系

目录 词性标注 实体名称标准化 实体关系标准化和提取 单词模式 文本分割 断句 断句的方式 使用正则表达式进行断句 词性标注 词性&#xff08;POS&#xff09;标注可以使用语言模型来完成&#xff0c;这个语言模型包含词及其所有可能词性组成的字典。然后&#xff0c;该…...

vector类

一、STL库 vector 1.1 vector的介绍 vector英文意思为向量&#xff1a;向量是表示大小可以改变的数组的序列容器。 指向其元素的常规指针上的偏移量来访问其元素&#xff0c;并且与数组中的效率一样高。但与数组不同&#xff0c;它们的大小可以动态变化&#xff0c;其存储由容…...

python常见的魔术方法

什么是魔术方法 Python类的内置方法&#xff0c;各自有各自的特殊功能&#xff0c;被称之为魔术方法 常见的魔术方法有以下&#xff1a; __init__:构造方法 __str__:字符串方法 __lt__:小于、大于符号比较 __le__:小于等于、大于等于符合比较 __eq__:等于符合比较__init__ c…...

自动化测试常用函数:弹窗、等待、导航、上传与参数设置

目录 一、弹窗 1. 警告弹窗确认弹窗 2. 提示弹窗 二、等待 1. 强制等待 2. 隐式等待 3. 显示等待 三、浏览器导航 1. 打开网站 2. 浏览器的前进、后退、刷新 四、文件上传 五、浏览器参数设置 1. 设置无头模式 2. 页面加载策略 一、弹窗 弹窗是在页面是找不到任何…...

【必看】2024国赛选题分布情况分析及数模国赛答辩指南~答辩不走弯路

↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 紧张刺激的数模国赛已经过去一段时间&#xff0c;各赛区的成绩发布也在陆续进…...

微服务注册中⼼1

1. 微服务的注册中⼼ 注册中⼼可以说是微服务架构中的”通讯录“ &#xff0c;它记录了服务和服务地址的映射关系。在分布式架构中&#xff0c; 服务会注册到这⾥&#xff0c;当服务需要调⽤其它服务时&#xff0c;就这⾥找到服务的地址&#xff0c;进⾏调⽤。 1.1 注册中⼼的…...

我设置了路由器自动切换ip,这会让我的账号登录地址经常改变吗

是的&#xff0c;路由器设置自动切换IP可能会导致你的账号登录地址经常改变。 这是因为当路由器切换IP时&#xff0c;外部网络所看到的你的设备IP地址也会随之改变。对于很多跨境电商、社交媒体或者银行账户等需要较高安全性的系统来说&#xff0c;经常变动的IP地址可能会被视…...

React hook之useRef

React useRef 详解 useRef 是 React 提供的一个 Hook&#xff0c;用于在函数组件中创建可变的引用对象。它在 React 开发中有多种重要用途&#xff0c;下面我将全面详细地介绍它的特性和用法。 基本概念 1. 创建 ref const refContainer useRef(initialValue);initialValu…...

深入浅出:JavaScript 中的 `window.crypto.getRandomValues()` 方法

深入浅出&#xff1a;JavaScript 中的 window.crypto.getRandomValues() 方法 在现代 Web 开发中&#xff0c;随机数的生成看似简单&#xff0c;却隐藏着许多玄机。无论是生成密码、加密密钥&#xff0c;还是创建安全令牌&#xff0c;随机数的质量直接关系到系统的安全性。Jav…...

《Playwright:微软的自动化测试工具详解》

Playwright 简介:声明内容来自网络&#xff0c;将内容拼接整理出来的文档 Playwright 是微软开发的自动化测试工具&#xff0c;支持 Chrome、Firefox、Safari 等主流浏览器&#xff0c;提供多语言 API&#xff08;Python、JavaScript、Java、.NET&#xff09;。它的特点包括&a…...

【网络安全产品大调研系列】2. 体验漏洞扫描

前言 2023 年漏洞扫描服务市场规模预计为 3.06&#xff08;十亿美元&#xff09;。漏洞扫描服务市场行业预计将从 2024 年的 3.48&#xff08;十亿美元&#xff09;增长到 2032 年的 9.54&#xff08;十亿美元&#xff09;。预测期内漏洞扫描服务市场 CAGR&#xff08;增长率&…...

论文笔记——相干体技术在裂缝预测中的应用研究

目录 相关地震知识补充地震数据的认识地震几何属性 相干体算法定义基本原理第一代相干体技术&#xff1a;基于互相关的相干体技术&#xff08;Correlation&#xff09;第二代相干体技术&#xff1a;基于相似的相干体技术&#xff08;Semblance&#xff09;基于多道相似的相干体…...

windows系统MySQL安装文档

概览&#xff1a;本文讨论了MySQL的安装、使用过程中涉及的解压、配置、初始化、注册服务、启动、修改密码、登录、退出以及卸载等相关内容&#xff0c;为学习者提供全面的操作指导。关键要点包括&#xff1a; 解压 &#xff1a;下载完成后解压压缩包&#xff0c;得到MySQL 8.…...

【前端异常】JavaScript错误处理:分析 Uncaught (in promise) error

在前端开发中&#xff0c;JavaScript 异常是不可避免的。随着现代前端应用越来越多地使用异步操作&#xff08;如 Promise、async/await 等&#xff09;&#xff0c;开发者常常会遇到 Uncaught (in promise) error 错误。这个错误是由于未正确处理 Promise 的拒绝&#xff08;r…...

学习一下用鸿蒙​​DevEco Studio HarmonyOS5实现百度地图

在鸿蒙&#xff08;HarmonyOS5&#xff09;中集成百度地图&#xff0c;可以通过以下步骤和技术方案实现。结合鸿蒙的分布式能力和百度地图的API&#xff0c;可以构建跨设备的定位、导航和地图展示功能。 ​​1. 鸿蒙环境准备​​ ​​开发工具​​&#xff1a;下载安装 ​​De…...

0x-3-Oracle 23 ai-sqlcl 25.1 集成安装-配置和优化

是不是受够了安装了oracle database之后sqlplus的简陋&#xff0c;无法删除无法上下翻页的苦恼。 可以安装readline和rlwrap插件的话&#xff0c;配置.bahs_profile后也能解决上下翻页这些&#xff0c;但是很多生产环境无法安装rpm包。 oracle提供了sqlcl免费许可&#xff0c…...

C#最佳实践:为何优先使用as或is而非强制转换

C#最佳实践&#xff1a;为何优先使用as或is而非强制转换 在 C# 的编程世界里&#xff0c;类型转换是我们经常会遇到的操作。就像在现实生活中&#xff0c;我们可能需要把不同形状的物品重新整理归类一样&#xff0c;在代码里&#xff0c;我们也常常需要将一个数据类型转换为另…...