优化:文章目录结构(某分类/YYYY/MM/dd/xxx.md)
@@ -9,9 +9,9 @@ export const sidebar: DefaultTheme.Config['sidebar'] = {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 年/月/日.xxmd 的目录格式, 获取侧边栏分组及分组下标题
|
||||
* 根据 某分类/YYYY/MM/dd/xxx.md 的目录格式, 获取侧边栏分组及分组下标题
|
||||
*
|
||||
* /repos/issues/2022/07/20.xxx.md
|
||||
* /categories/issues/2022/07/20/xxx.md
|
||||
*
|
||||
* @param path 扫描基础路径
|
||||
* @returns {DefaultTheme.SidebarGroup[]}
|
||||
@@ -34,24 +34,31 @@ function getItemsByDate (path: string) {
|
||||
objectMode: true
|
||||
}).forEach(({ name }) => {
|
||||
let month = name
|
||||
// 3.获取月份目录下的所有文章
|
||||
// 3.获取所有日期目录
|
||||
sync(`repos/${path}/${year}/${month}/*`, {
|
||||
onlyFiles: true,
|
||||
onlyDirectories: true,
|
||||
objectMode: true
|
||||
}).forEach(({ name }) => {
|
||||
// 向前追加标题
|
||||
items.unshift({
|
||||
text: name,
|
||||
link: `/${path}/${year}/${month}/${name}`
|
||||
let day = name
|
||||
// 4.获取日期目录下的所有文章
|
||||
sync(`repos/${path}/${year}/${month}/${day}/*`, {
|
||||
onlyFiles: true,
|
||||
objectMode: true
|
||||
}).forEach(({ name }) => {
|
||||
// 向前追加标题
|
||||
items.unshift({
|
||||
text: name,
|
||||
link: `/${path}/${year}/${month}/${day}/${name}`
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// 4.向前追加到分组
|
||||
// 5.向前追加到分组
|
||||
if (items.length > 0) {
|
||||
// 去除标题名中的日期前缀和扩展名
|
||||
// 去除标题名中的扩展名
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let text = items[i].text
|
||||
items[i].text = text.replace('.md', '').substring(text.indexOf('.') + 1)
|
||||
items[i].text = text.replace('.md', '')
|
||||
}
|
||||
groups.unshift({
|
||||
text: `${year}年${month}月 (${items.length}篇)`,
|
||||
@@ -61,20 +68,20 @@ function getItemsByDate (path: string) {
|
||||
})
|
||||
}
|
||||
|
||||
// 5.清空侧边栏分组下标题数组
|
||||
// 6.清空侧边栏分组下标题数组
|
||||
items = []
|
||||
})
|
||||
})
|
||||
|
||||
// 6.将第一个侧边栏分组的标题展开
|
||||
// 7.将第一个侧边栏分组的标题展开
|
||||
groups[0].collapsed = false
|
||||
return groups
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 分组/序号.xxmd 的目录格式, 获取侧边栏分组及分组下标题
|
||||
* 根据 某小课/序号-分组/序号-xxx.md 的目录格式, 获取侧边栏分组及分组下标题
|
||||
*
|
||||
* /repos/courses/mybatis/MyBatis基础/20.xxx.md
|
||||
* courses/mybatis/01-MyBatis基础/01-xxx.md
|
||||
*
|
||||
* @param path 扫描基础路径
|
||||
* @returns {DefaultTheme.SidebarGroup[]}
|
||||
@@ -105,13 +112,13 @@ function getItems (path: string) {
|
||||
|
||||
// 3.向前追加到分组
|
||||
if (items.length > 0) {
|
||||
// 去除标题名中的日期前缀和扩展名
|
||||
// 去除标题名中的前缀和扩展名
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let text = items[i].text
|
||||
items[i].text = text.replace('.md', '').substring(text.indexOf('.') + 1)
|
||||
items[i].text = text.replace('.md', '').substring(text.indexOf('-') + 1)
|
||||
}
|
||||
groups.push({
|
||||
text: `${groupName.substring(groupName.indexOf('.') + 1)} (${items.length}篇)`,
|
||||
text: `${groupName.substring(groupName.indexOf('-') + 1)} (${items.length}篇)`,
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: items
|
||||
|
@@ -45,7 +45,7 @@ tags:
|
||||
cd eladminx
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
2. 将前端仓库作为后端仓库的远程仓库,起别名为 frontend(这个随便起)
|
||||
|
||||
@@ -53,7 +53,7 @@ tags:
|
||||
git remote add -f frontend https://gitee.com/Charles7c/eladminx-web.git
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
3. 将前端仓库的 master 分支(自己选择哪个分支)合并到后端仓库
|
||||
|
||||
@@ -61,7 +61,7 @@ tags:
|
||||
git merge --strategy ours --no-commit frontend/master
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
想法很美,但是报错了:
|
||||
|
||||
@@ -75,7 +75,7 @@ tags:
|
||||
git merge --strategy ours --allow-unrelated-histories --no-commit frontend/master
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
4. 将前端仓库的 master 分支内容放到在后端仓库内刚建好的 eladminx-web 文件夹中
|
||||
|
@@ -14,7 +14,7 @@ tags:
|
||||
|
||||
近期打开移动硬盘时,经常弹出一个提示框,提示内容是:**F:\ 上的"回收站"已损坏。是否清空该驱动器上的"回收站"?**
|
||||
|
||||

|
||||

|
||||
|
||||
这个提示框出现过好多回了,除了第一次见到时担心数据丢失,所以比较重视,后来次数多了,点过 “是”,也点过 “否”,只要当下不再影响我就先忽略了。
|
||||
|
||||
@@ -38,7 +38,7 @@ tags:
|
||||
|
||||
我又考虑是不是电脑本次出了点故障,于是我重启了电脑。
|
||||
|
||||

|
||||

|
||||
|
||||
果然,问题还是没解决了。
|
||||
|
||||
@@ -66,6 +66,6 @@ tags:
|
||||
rd /s f:\$RECYCLE.BIN
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
问题解决了。
|
@@ -17,7 +17,7 @@ tags:
|
||||
|
||||
结果,刚握住水杯,就看到 IntelliJ IDEA 在左下角弹出了一个错误提示框,如下:
|
||||
|
||||

|
||||

|
||||
|
||||
看提示的意思是命令行太长了,让缩短一下命令行。又点了两下【Debug】运行按钮,依然不依不饶的弹出这个提示,那就放下水杯解决吧。
|
||||
|
||||
@@ -46,7 +46,7 @@ tags:
|
||||
|
||||
双击打开项目根目录下的 `.idea` 目录,这个目录下都是 IntelliJ IDEA 自动保存的项目配置内容,一般情况下我们不需要关注它,但这次我们需要找到其中的 `workspace.xml` 配置文件,手动修改一下配置。
|
||||
|
||||

|
||||

|
||||
|
||||
按下 【Ctrl + F】,在弹出的搜索框中,输入【PropertiesComponent】回车,定位到该项配置后,在其所在的 `<component>` 标签内最后部分添加一条属性配置,如下:
|
||||
|
||||
@@ -54,6 +54,6 @@ tags:
|
||||
<property name="dynamic.classpath" value="true" />
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
添加完后,关闭该配置文件即可,再次点击【Debug】运行按钮,项目正常启动了,笔者也该去接水了。
|
@@ -18,7 +18,7 @@ tags:
|
||||
|
||||
不过好在最后问题解决了,跟笔者来一起看看解决方法吧。
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## 解决方案
|
||||
@@ -26,15 +26,15 @@ tags:
|
||||
|
||||
首先,在出现问题的磁盘上【右键】单击,然后选择【属性】。
|
||||
|
||||

|
||||

|
||||
|
||||
在弹出的【属性】对话框中,选择【工具】选项卡,然后点击【检查】按钮。这个功能是用来检查磁盘文件系统错误的,检查完还会有个错误修复的环节。
|
||||
|
||||

|
||||

|
||||
|
||||
可惜的是,不知道是笔者这台电脑登录的账号权限问题,还是系统错误,这项修复手段,笔者用不了。
|
||||
|
||||

|
||||

|
||||
|
||||
### 尝试2:命令行修复
|
||||
|
||||
@@ -42,7 +42,7 @@ tags:
|
||||
|
||||
按下【Windows】键,弹出【开始】菜单,直接输入【cmd】来在菜单中搜索。搜索出来后,在【cmd.exe/命令行】上【右键】单击,选择【以管理员身份运行】。
|
||||
|
||||

|
||||

|
||||
|
||||
在弹出的 CMD 命令行窗口中,输入以下命令:
|
||||
|
||||
@@ -51,10 +51,10 @@ tags:
|
||||
chkdsk f: /f
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
等待检查修复结束,笔者的 F 盘又回来了。
|
||||
|
||||

|
||||

|
@@ -66,7 +66,7 @@ tags:
|
||||
|
||||
在前端表单中的展示效果大概如下:
|
||||
|
||||

|
||||

|
||||
|
||||
## 原因分析
|
||||
|
||||
@@ -78,7 +78,7 @@ tags:
|
||||
|
||||
最终,配合前端开发定位这个问题的原因是因为: JavaScript 中无法存储 Java 中的 Long 类型数据,当位数超过 JavaScript 整数存储的范围,就会以0来代替了。
|
||||
|
||||

|
||||

|
||||
|
||||
## 解决方案
|
||||
|
@@ -64,15 +64,15 @@ INSERT INTO `user` VALUES (5, 'Billie', 24, 'Billie@126.com');
|
||||
|
||||
要使用 MyBatis 框架,第一步就是下载好 MyBatis 的 jar 包,我们可以从 [MyBatis](https://github.com/mybatis/mybatis-3/releases) 在 GitHub 上的开源地址下载。
|
||||
|
||||

|
||||

|
||||
|
||||
笔者下载了 MyBatis 的核心压缩包(mybatis-x.x.x.zip)及其源码包(mybatis-x-mybatis-x.x.x.zip)。
|
||||
|
||||

|
||||

|
||||
|
||||
解压开 **mybatis-3.5.6.zip** 压缩包,目录结构如下:
|
||||
|
||||

|
||||

|
||||
|
||||
::: tip 笔者说
|
||||
如果 GitHub 下载太慢,可以前往 [FastGit](https://hub.fastgit.org/mybatis/mybatis-3/releases/tag/mybatis-3.5.6) 进行下载,它是 GitHub 的镜像地址,网站界面等各方面与 GitHub 几乎一模一样。
|
||||
@@ -83,7 +83,7 @@ INSERT INTO `user` VALUES (5, 'Billie', 24, 'Billie@126.com');
|
||||
|
||||
下载好依赖之后,我们通过 Eclipse,创建一个动态 Web 项目,并将刚才下载的 jar 包和指定数据库驱动包添加到 WebConent\WEB-INF\lib 目录,效果如下:
|
||||
|
||||

|
||||

|
||||
|
||||
::: tip 笔者说
|
||||
本次我们不会使用到 Servlet API,所以创建一个普通 Java 工程也没问题。
|
||||
@@ -202,7 +202,7 @@ log4j.appender.CONSOLE.layout.ConversionPattern=[demo] %d{yyyy-MM-dd HH:mm:ss,SS
|
||||
|
||||
当一切准备好之后,完整的项目目录结构如下:
|
||||
|
||||

|
||||

|
||||
|
||||
创建好一个单元测试类,测试一下:
|
||||
|
@@ -17,7 +17,7 @@ tags:
|
||||
|
||||
在 API 使用层面,MyBatis 的核心类型有三个,分别是:SqlSessionFactoryBuilder、SqlSessionFactory、SqlSession。
|
||||
|
||||

|
||||

|
||||
|
||||
## SqlSessionFactoryBuilder
|
||||
|
||||
@@ -179,8 +179,6 @@ void testSelectList() throws IOException {
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
::: info 笔者说
|
||||
对于技术的学习,笔者一贯遵循的步骤是:先用最最简单的 demo 让它跑起来,然后学学它的最最常用 API 和 配置让自己能用起来,最后熟练使用的基础上,在空闲时尝试阅读它的源码让自己能够洞彻它的运行机制,部分问题出现的原因,同时借鉴这些技术实现来提升自己的代码高度。
|
||||
所以在笔者的文章中,前期基本都是小白文,仅仅穿插很少量的源码研究。当然等小白文更新多了,你们还依然喜欢,后期会不定时专门对部分技术的源码进行解析。
|
@@ -38,7 +38,7 @@ configuration 根节点
|
||||
::: tip 笔者说
|
||||
这些标签在使用时一定要注意标签的顺序和允许使用次数。Eclipse 中可以通过在标签上按 F2 查看该标签下的内容模型,即标签的顺序和允许使用次数。你看下图中画圈处就是各个标签的顺序,后面的 ?号 代表指定标签最多允许使用一次。
|
||||
:::
|
||||

|
||||

|
||||
|
||||
## properties元素
|
||||
|
||||
@@ -352,7 +352,7 @@ mappers 元素的作用就是用来告诉 MyBatis 去哪找我们编写的 SQL
|
||||
|
||||
### 指定映射文件
|
||||
|
||||
这类方式主要是告诉 MyBatis 我们所编写的 SQL 映射文件的地址,我们之前在 [《快速入门》](./01.快速入门) 中使用的就是属于这类方式。它有两种实现:
|
||||
这类方式主要是告诉 MyBatis 我们所编写的 SQL 映射文件的地址,我们之前在 [《快速入门》](./01-快速入门) 中使用的就是属于这类方式。它有两种实现:
|
||||
|
||||
```xml
|
||||
<!-- 使用相对于类路径的资源引用,有多少 SQL 映射文件就写多少个 mapper 配置 -->
|
||||
@@ -395,7 +395,7 @@ public interface UserMapper {
|
||||
}
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
**第二步:将 SQL 映射文件的 namespace 值改为对应 Mapper 接口的全限定类名。**
|
||||
|
@@ -72,7 +72,7 @@ public class UserDaoImpl extends BaseDao implements UserDao {
|
||||
|
||||
有问题存在,就不缺解决问题的人。在行业内随之诞生了大量的持久层解决方案,除了各自公司自研的方案之外,比较有名的通用开源方案有:Hibernate、MyBatis等,各有各的优劣势,在此我先不谈论它们的区别,只说一个现象:在国内来讲MyBatis应用相对广泛。
|
||||
|
||||

|
||||

|
||||
|
||||
所以那没什么好说的了,直接学吧?
|
||||
|
||||
@@ -86,14 +86,14 @@ MyBatis读音是:[mai'bətɪs](买杯涕死),原是 Apache 软件基金会
|
||||
MyBatis 是一款优秀的 **半自动的持久层ORM框架** ,它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接口和 Java POJO(Plain Old Java Objects,普通老式 Java 对象)为数据库中的记录。
|
||||
|
||||
当前,最新版本是MyBatis 3.5.6 ,其发布时间是2020年10月6日。[1]
|
||||

|
||||

|
||||
:::
|
||||
|
||||
::: details **1.什么是 ORM ?** [2]
|
||||
ORM,对象关系映射(Object Relation Mapping,简称ORM,或O/RM,或O/R Mapping),它是随着面向对象的软件开发方法发展而产生的。
|
||||
|
||||
面向对象的开发方法是当今企业级应用开发环境中的主流开发方法,关系数据库是企业级应用环境中永久存放数据的主流数据存储系统。对象和关系数据是业务实体的两种表现形式,业务实体在内存中表现为对象,在数据库中表现为关系数据。内存中的对象之间存在关联和继承关系,而在数据库中,关系数据无法直接表达多对多关联和继承关系。因此,对象-关系映射( ORM )系统一般以中间件的形式存在,主要实现程序对象到关系数据库数据的映射。
|
||||

|
||||

|
||||
|
||||
面向对象是从软件工程基本原则(如耦合、聚合、封装)的基础上发展起来的,而关系数据库则是从数学理论发展而来的,两套理论存在显著的区别。为了解决这个不匹配的现象,对象关系映射技术应运而生。
|
||||
|
||||
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 217 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |