From b2fe8abe1f51fecc6303b19d88da1ece787996da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E7=A5=A5?= <1366971433@qq.com> Date: Thu, 22 Aug 2019 15:17:10 +0800 Subject: [PATCH] spring --- .../spring-druid-mybatis-annotation/README.md | 42 ++++++++++--------- spring/spring-druid-mybatis/README.md | 36 ++++++++-------- spring/spring-memcached-annotation/README.md | 18 ++++---- spring/spring-memcached/README.md | 2 + spring/spring-mybatis-annotation/README.md | 28 ++++++------- spring/spring-mybatis/README.md | 29 ++++++------- spring/spring-redis-annotation/README.md | 19 +++++---- spring/spring-redis/README.md | 15 +++---- 8 files changed, 102 insertions(+), 87 deletions(-) diff --git a/spring/spring-druid-mybatis-annotation/README.md b/spring/spring-druid-mybatis-annotation/README.md index 8715021..4a6c7b5 100644 --- a/spring/spring-druid-mybatis-annotation/README.md +++ b/spring/spring-druid-mybatis-annotation/README.md @@ -1,21 +1,25 @@ # Spring +Druid+ Mybatis(注解方式) + + + ### 项目目录结构
-#### 1. 导入依赖 + + +### 1. 导入依赖 创建 maven 工程,除了 Spring 的基本依赖外,还需要导入 Mybatis 和 Druid 的相关依赖: @@ -55,7 +59,7 @@ ``` -#### 2. 配置前端控制器 +### 2. 配置前端控制器 新建 DispatcherServletInitializer 继承自 AbstractAnnotationConfigDispatcherServletInitializer,等价于在 web.xml 方式中配置的前端控制器: @@ -76,7 +80,7 @@ public class DispatcherServletInitializer extends AbstractAnnotationConfigDispat } ``` -#### 3. 配置 Druid 监控 +### 3. 配置 Druid 监控 基于 servlet 3.0 的支持,可以采用注解的方式注册 druid 的 servlet 和 filter。关于 servlet 更多注解支持可以查看 [Servlet 规范文档](https://github.com/heibaiying/spring-samples-for-all/blob/master/referenced%20documents/Servlet3.1%E8%A7%84%E8%8C%83%EF%BC%88%E6%9C%80%E7%BB%88%E7%89%88%EF%BC%89.pdf) 中的 **8.1 小节 注解和可插拔性** @@ -103,7 +107,7 @@ public class DruidStatFilter extends WebStatFilter { } ``` -#### 4. 数据库配置 +### 4. 数据库配置 在 resources 文件夹下新建数据库配置文件及其映射类: @@ -141,7 +145,7 @@ public class DataSourceConfig { } ``` -#### 5. Druid 连接池配置 +### 5. Druid 连接池配置 新建 ServletConfig,进行数据库相关配置: @@ -242,7 +246,7 @@ public class ServletConfig implements WebMvcConfigurer { } ``` -#### 6. MyBatis 配置 +### 6. MyBatis 配置 新建 mybtais 配置文件,按照需求配置额外参数, 更多 settings 配置项可以参考 [官方文档]( @@ -264,7 +268,7 @@ public class ServletConfig implements WebMvcConfigurer { ``` -#### 7. 数据查询 +### 7. 数据查询 新建查询接口及其实现类,以下示例分别查询的是 MySQL 和 Oracle 中的字典表: @@ -313,7 +317,7 @@ public interface OracleDao { ``` -#### 8. 测试查询 +### 8. 测试查询 新建测试类进行测试: @@ -345,7 +349,7 @@ public class OracleController { } ``` -#### 9. Druid 监控台 +### 9. Druid 监控台 Druid Web 页面访问地址为:http://localhost:8080/druid/index.html,可以登录后查看数据库相关监控数据: diff --git a/spring/spring-druid-mybatis/README.md b/spring/spring-druid-mybatis/README.md index 3d4beaa..59740da 100644 --- a/spring/spring-druid-mybatis/README.md +++ b/spring/spring-druid-mybatis/README.md @@ -1,22 +1,24 @@ # Spring +Druid+ Mybatis(XML 配置方式) + + + ### 项目目录结构
-#### 1. 导入依赖 +### 1. 导入依赖 创建 maven 工程,除了 Spring 的基本依赖外,还需要导入 Mybatis 和 Druid 的相关依赖: @@ -56,7 +58,7 @@ ``` -#### 2. web.xml 配置 +### 2. web.xml 配置 在 `web.xml` 中配置 Spring 的前端控制器以及 Druid 的 Web 监控台,用于获取数据库的相关监控信息: @@ -126,7 +128,7 @@ ``` -#### 3. 数据库配置 +### 3. 数据库配置 在 resources 文件夹下新建数据库配置文件 `jdbc.properties`: @@ -142,7 +144,7 @@ oracle.username=用户名 oracle.password=密码 ``` -#### 4. Druid 连接池配置 +### 4. Druid 连接池配置 在 resources 文件夹下创建 `springApplication.xml` 配置文件和 `druid.xml` 配置文件: @@ -254,7 +256,7 @@ oracle.password=密码 ``` -#### 5. MyBatis 配置 +### 5. MyBatis 配置 新建 mybtais 配置文件,按照需求配置额外参数, 更多 settings 配置项可以参考 [官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html) @@ -276,7 +278,7 @@ oracle.password=密码 ``` -#### 6. 数据查询 +### 6. 数据查询 新建查询接口及其实现类,以下示例分别查询的是 MySQL 和 Oracle 中的字典表: @@ -325,7 +327,7 @@ public interface OracleDao { ``` -#### 7. 测试查询 +### 7. 测试查询 新建测试类进行测试: @@ -357,7 +359,7 @@ public class OracleController { } ``` -#### 8. Druid 监控台 +### 8. Druid 监控台 Druid Web 页面访问地址为:http://localhost:8080/druid/index.html,可以登录后查看数据库相关监控数据: diff --git a/spring/spring-memcached-annotation/README.md b/spring/spring-memcached-annotation/README.md index abcb5d5..e629035 100644 --- a/spring/spring-memcached-annotation/README.md +++ b/spring/spring-memcached-annotation/README.md @@ -6,10 +6,10 @@         1.2 项目结构
        1.3 相关依赖
二、整合 XMemcached
-                2.1 单机配置
-                2.2 集群配置
-                2.3 存储基本类型测试用例
-                2.5 存储实体对象测试用例
+        2.1 单机配置
+        2.2 集群配置
+        2.3 存储基本类型测试用例
+        2.4 存储实体对象测试用例
附:Memcached 基本命令
@@ -24,6 +24,8 @@ XMemcached 是基于 Java NIO 实现的 Memcached 的高性能客户端,支持 Memcached 的整合配置位于 com.heibaiying.config 文件夹下:
+ + ### 1.3 相关依赖 除了 Spring 的基本依赖外,需要导入 xmemcached 依赖包: @@ -41,7 +43,7 @@ Memcached 的整合配置位于 com.heibaiying.config 文件夹下: ## 二、整合 XMemcached -#### 2.1 单机配置 +### 2.1 单机配置 ```java @Bean @@ -57,7 +59,7 @@ try { } ``` -#### 2.2 集群配置 +### 2.2 集群配置 ```java @Bean @@ -87,7 +89,7 @@ public MemcachedClient memcachedClientForCluster() { } ``` -#### 2.3 存储基本类型测试用例 +### 2.3 存储基本类型测试用例 XMemcached 单机版和集群版注入的实例是完全相同的: @@ -111,7 +113,7 @@ public class MemSamples { } ``` -#### 2.5 存储实体对象测试用例 +### 2.4 存储实体对象测试用例 ```java @RunWith(SpringRunner.class) diff --git a/spring/spring-memcached/README.md b/spring/spring-memcached/README.md index db48855..990a535 100644 --- a/spring/spring-memcached/README.md +++ b/spring/spring-memcached/README.md @@ -25,6 +25,8 @@ XMemcached 是基于 Java NIO 实现的 Memcached 的高性能客户端,支持 - 实体类 Programmer 用于测试 Memcached 的序列化与反序列化。
+ + **springapplication.xml 文件:** ```xml diff --git a/spring/spring-mybatis-annotation/README.md b/spring/spring-mybatis-annotation/README.md index bbd5443..399a354 100644 --- a/spring/spring-mybatis-annotation/README.md +++ b/spring/spring-mybatis-annotation/README.md @@ -2,23 +2,23 @@ ## 一、项目说明 -#### 1.1 项目结构 +### 1.1 项目结构
-#### 1.2 项目依赖 +### 1.2 项目依赖 除了 Spring 相关依赖外,还需要导入数据库驱动和对应的 Mybatis 依赖: @@ -54,7 +54,7 @@ ## 二、整合 Mybatis -#### 2.1 数据库配置 +### 2.1 数据库配置 在 resources 文件夹下新建数据库配置文件 jdbc.properties: @@ -90,7 +90,7 @@ public class DataSourceConfig { } ``` -#### 2.2 配置数据源 +### 2.2 配置数据源 配置数据源、Mybatis 会话工厂和事务管理器: @@ -158,7 +158,7 @@ public class DatabaseConfig { } ``` -#### 2.3 MyBatis 配置 +### 2.3 MyBatis 配置 新建mybtais配置文件,按照需求配置额外参数, 更多 settings 配置项可以参考 [官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html) @@ -182,7 +182,7 @@ public class DatabaseConfig { ``` -#### 2.4 数据查询 +### 2.4 数据查询 新建查询接口及其实现类,以下示例分别查询的是 MySQL 和 Oracle 中的字典表: @@ -231,7 +231,7 @@ public interface OracleDao { ``` -#### 2.5 测试查询 +### 2.5 测试查询 新建测试类进行测试: diff --git a/spring/spring-mybatis/README.md b/spring/spring-mybatis/README.md index 24c4534..8a5df78 100644 --- a/spring/spring-mybatis/README.md +++ b/spring/spring-mybatis/README.md @@ -2,23 +2,24 @@ ## 一、项目说明 -#### 1.1 项目结构 +### 1.1 项目结构
-#### 1.2 项目依赖 + +### 1.2 项目依赖 除了 Spring 相关依赖外,还需要导入数据库驱动和对应的 Mybatis 依赖: @@ -54,7 +55,7 @@ ## 二、整合 Mybatis -#### 2.1 数据库配置 +### 2.1 数据库配置 在 resources 文件夹下新建数据库配置文件 jdbc.properties: @@ -72,7 +73,7 @@ oracle.username=用户名 oracle.password=密码 ``` -#### 2.2 配置数据源 +### 2.2 配置数据源 配置数据源、Mybatis 会话工厂和事务管理器: @@ -134,7 +135,7 @@ oracle.password=密码 ``` -#### 2.3 MyBatis 配置 +### 2.3 MyBatis 配置 新建mybtais配置文件,按照需求配置额外参数, 更多 settings 配置项可以参考 [官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html) @@ -159,7 +160,7 @@ oracle.password=密码 ``` -#### 2.4 数据查询 +### 2.4 数据查询 新建查询接口及其实现类,以下示例分别查询的是 MySQL 和 Oracle 中的字典表: @@ -207,7 +208,7 @@ public interface OracleDao { ``` -#### 2.5 测试查询 +### 2.5 测试查询 新建测试类进行测试: diff --git a/spring/spring-redis-annotation/README.md b/spring/spring-redis-annotation/README.md index 5d79b2e..1a050ba 100644 --- a/spring/spring-redis-annotation/README.md +++ b/spring/spring-redis-annotation/README.md @@ -1,10 +1,10 @@ # Spring 整合 Redis (注解方式) -## 一、说明 -### 1.1 客户端说明 +## 一、项目说明 + +### 1.1 Redis客户端 关于 spring 整合 Redis 本用例提供两种整合方法: @@ -32,11 +33,12 @@
+ ### 1.2 可视化软件 推荐使用 **Redis Desktop Manager** 作为可视化查看工具,可以直观看到存储的数据及其序列化的情况。 -### 1.3 项目结构说明 +### 1.3 项目结构 + Jedis 和 Redisson 的配置类和单元测试分别位于 config 和 test 下对应的包中,其中集群的配置类以 cluster 开头。 @@ -44,7 +46,8 @@
-### 1.4 依赖说明 + +### 1.4 基本依赖 除了 Spring 的基本依赖外,需要导入 Jedis 和 Redisson 对应的客户端依赖: diff --git a/spring/spring-redis/README.md b/spring/spring-redis/README.md index b6dea36..499f4a5 100644 --- a/spring/spring-redis/README.md +++ b/spring/spring-redis/README.md @@ -1,11 +1,11 @@ # Spring 整合 Redis ( XML配置方式) +### 一、项目说明 -## 一、说明 - -### 1.1 客户端说明 +### 1.1 Redis客户端 关于 spring 整合 Redis 本用例提供两种整合方法: @@ -45,6 +44,8 @@ + 实体类 Programmer 用于测试 Redisson 序列化与反序列化。
+ + **springapplication.xml 文件:** ```xml @@ -68,7 +69,7 @@ ``` -### 1.4 依赖说明 +### 1.4 基本依赖 除了 Spring 的基本依赖外,需要导入 Jedis 和 Redisson 对应的客户端依赖: