diff --git a/spring/spring-aop-annotation/README.md b/spring/spring-aop-annotation/README.md
index ce8be68..ea42eb6 100644
--- a/spring/spring-aop-annotation/README.md
+++ b/spring/spring-aop-annotation/README.md
@@ -1,37 +1,35 @@
-# spring AOP(注解方式)
+# Spring AOP(注解方式)
-## 目录
+
## 一、说明
### 1.1 项目结构说明
-1. 切面配置位于 com.heibaiying.config 下 AopConfig.java 文件;
-2. 自定义切面位于 advice 下,其中 CustomAdvice 是标准的自定义切面,FirstAdvice 和 SecondAdvice 用于测试多切面共同作用于同一个被切入点时的执行顺序;
-3. OrderService 是待切入方法。
+1. 切面配置位于 com.heibaiying.config 下 `AopConfig` ;
+2. 自定义切面位于 advice 包下,其中 `CustomAdvice` 是标准的自定义切面,`FirstAdvice` 和 `SecondAdvice` 用于测试多切面共同作用于同一个切入点时的执行顺序;
+3. `OrderService` 是待切入方法。
-
### 1.2 依赖说明
-除了 spring 的基本依赖外,需要导入 aop 依赖包
+除了 Spring 的基本依赖外,需要导入 AOP 依赖包:
```xml
-
+
org.springframework
spring-aop
@@ -41,9 +39,11 @@
-## 二、spring aop
+## 二、Spring AOP
-#### 2.1 创建待切入接口及其实现类
+### 2.1 准备工作
+
+创建待切入的接口及其实现类:
```java
public interface OrderService {
@@ -67,18 +67,13 @@ public class OrderServiceImpl implements OrderService {
return new Order(id, "new Product", new Date());
}
}
-
```
-#### 2.2 创建自定义切面类
+### 2.2 自定义切面类
-注:@Pointcut 的值可以是多个切面表达式的组合。
+使用 @Aspect 来定义切面类,@Pointcut 来定义切面表达式,它可以是多个切面表达式的组合:
```java
-/**
- * @author : heibaiying
- * @description : 自定义切面
- */
@Aspect
@Component //除了加上@Aspect 外 还需要声明为 spring 的组件 @Aspect 只是一个切面声明
public class CustomAdvice {
@@ -132,13 +127,9 @@ public class CustomAdvice {
```
-#### 2.3 配置切面
+### 2.3 配置切面
```java
-/**
- * @author : heibaiying
- * @description : 开启切面配置
- */
@Configuration
@ComponentScan("com.heibaiying.*")
@EnableAspectJAutoProxy // 开启@Aspect 注解支持 等价于
@@ -146,7 +137,7 @@ public class AopConfig {
}
```
-#### 2.4 测试切面
+### 2.4 测试切面
```java
@RunWith(SpringRunner.class)
@@ -164,8 +155,8 @@ public class AopTest {
}
/**
- * 多个切面作用于同一个切入点时,可以用@Order 指定切面的执行顺序
- * 优先级高的切面在切入方法前执行的通知 (before) 会优先执行,但是位于方法后执行的通知 (after,afterReturning) 反而会延后执行
+ * 多个切面作用于同一个切入点时,可以用 @Order 指定切面的执行顺序
+ * 优先级高的切面在切入方法前执行的通知 (如 before) 会优先执行,但是位于方法后执行的通知 (如 after,afterReturning) 反而会延后执行
*/
@Test
public void delete() {
@@ -174,30 +165,30 @@ public class AopTest {
}
```
-#### 2.5 切面执行顺序
+### 2.5 切面执行顺序
-- 多个切面作用于同一个切入点时,可以用@Order 指定切面的执行顺序
+- 多个切面作用于同一个切入点时,可以用 @Order 指定切面的执行顺序。
-- 优先级高的切面在切入方法前执行的通知 (before) 会优先执行,但是位于方法后执行的通知 (after,afterReturning) 反而会延后执行,类似于同心圆原理。
+- 优先级高的切面在切入方法前执行的通知 ( 如 before) 会优先执行,但是位于方法后执行的通知 ( 如 after,afterReturning ) 反而会延后执行,类似于同心圆原理:
-## 附: 关于切面表达式的说明
+## 三、切面表达式
切面表达式遵循以下格式:
```shell
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern)
- throws-pattern?)
+throws-pattern?)
```
-- 除了返回类型模式,名字模式和参数模式以外,所有的部分都是可选的;
-- `*`,它代表了匹配任意的返回类型;
-- `()` 匹配了一个不接受任何参数的方法, 而 `(..)` 匹配了一个接受任意数量参数的方法(零或者更多)。 模式 `(*)` 匹配了一个接受一个任何类型的参数的方法。 模式 `(*,String)` 匹配了一个接受两个参数的方法,第一个可以是任意类型,第二个则必须是 String 类型。
+- 除了返回类型模式,名字模式和参数模式以外,所有的部分都是可选的。
+- `*` 代表了匹配任意的返回类型。
+- `()` 匹配一个不接受任何参数的方法, `(..)` 匹配一个接受任意数量参数的方法(零或者更多)。 `(*)` 匹配一个接受任意类型的参数的方法。 模式 `(*,String)` 匹配了一个接受两个参数的方法,第一个可以是任意类型,第二个则必须是 String 类型。
-下面给出一些常见切入点表达式的例子。
+下面为一些常见切入点表达式:
- 任意公共方法的执行:
@@ -205,25 +196,25 @@ execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-patter
execution(public * *(..))
```
-- 任何一个以“set”开始的方法的执行:
+- 任何一个以 `set` 开头的方法的执行:
```java
execution(* set*(..))
```
-- `AccountService` 接口的任意方法的执行:
+- `AccountService` 接口上任意方法的执行:
```java
execution(* com.xyz.service.AccountService.*(..))
```
-- 定义在 service 包里的任意方法的执行:
+- 定义在 service 包里任意方法的执行:
```java
execution(* com.xyz.service.*.*(..))
```
-- 定义在 service 包或者子包里的任意方法的执行:
+- 定义在 service 包或者子包里任意方法的执行:
```java
execution(* com.xyz.service..*.*(..))
@@ -247,4 +238,4 @@ execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-patter
this(com.xyz.service.AccountService)
```
-更多表达式可以参考官方文档:[Declaring a Pointcut](https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/core.html#aop-pointcuts)
+更多表达式可以参考官方文档:[Declaring a Pointcut](https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/core.html#aop-pointcuts)
\ No newline at end of file
diff --git a/spring/spring-aop/README.md b/spring/spring-aop/README.md
index 4159653..4bdcad6 100644
--- a/spring/spring-aop/README.md
+++ b/spring/spring-aop/README.md
@@ -1,34 +1,35 @@
-# spring AOP(xml配置方式)
-
-## 目录
+# spring AOP( XML 配置方式)
+
+
+##
## 一、说明
### 1.1 项目结构说明
-切面配置位于 resources 下的 aop.xml 文件,其中 CustomAdvice 是自定义切面类,OrderService 是待切入的方法。
+切面配置位于 resources 下的 `aop.xml` ,其中 CustomAdvice 是自定义切面类,OrderService 是待切入的方法。
-
### 1.2 依赖说明
-除了 spring 的基本依赖外,需要导入 aop 依赖包
+除了 Spring 的基本依赖外,还需需要导入 AOP 的依赖:
```xml
-
+
org.springframework
spring-aop
@@ -38,9 +39,11 @@
-## 二、spring aop
+## 二、Spring AOP
-#### 2.1 创建待切入接口及其实现类
+### 2.1 准备工作
+
+创建待切入的接口及其实现类:
```java
public interface OrderService {
@@ -64,20 +67,16 @@ public class OrderServiceImpl implements OrderService {
return new Order(id, "new Product", new Date());
}
}
-
```
-#### 2.2 创建自定义切面类
+### 2.2 自定义切面
```java
-/**
- * @author : heibaiying
- * @description : 自定义切面
- */
public class CustomAdvice {
-
- //前置通知
+ /**
+ *前置通知
+ */
public void before(JoinPoint joinPoint) {
//获取节点名称
String name = joinPoint.getSignature().getName();
@@ -85,12 +84,16 @@ public class CustomAdvice {
System.out.println(name + "方法调用前:获取调用参数" + Arrays.toString(args));
}
- //后置通知 (抛出异常后不会被执行)
+ /**
+ *后置通知 (抛出异常后不会被执行)
+ */
public void afterReturning(JoinPoint joinPoint, Object result) {
System.out.println("后置返回通知结果" + result);
}
- //环绕通知
+ /**
+ *环绕通知
+ */
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("环绕通知-前");
//调用目标方法
@@ -99,14 +102,16 @@ public class CustomAdvice {
return proceed;
}
- //异常通知
+ /**
+ *异常通知
+ */
public void afterException(JoinPoint joinPoint, Exception exception) {
System.err.println("后置异常通知:" + exception);
- }
+ };
- ;
-
- // 后置通知 总会执行 但是不能访问到返回值
+ /**
+ *后置通知 总会执行 但是不能访问到返回值
+ */
public void after(JoinPoint joinPoint) {
System.out.println("后置通知");
}
@@ -114,7 +119,7 @@ public class CustomAdvice {
```
-#### 2.3 配置切面
+### 2.3 配置切面
```xml
@@ -122,9 +127,9 @@ public class CustomAdvice {
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd">
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/aop
+ http://www.springframework.org/schema/aop/spring-aop.xsd">
@@ -154,7 +159,7 @@ public class CustomAdvice {
```
-#### 2.4 测试切面
+### 2.4 测试切面
```java
@RunWith(SpringRunner.class)
@@ -174,20 +179,20 @@ public class AopTest {
-## 附: 关于切面表达式的说明
+## 三、切面表达式
切面表达式遵循以下格式:
```shell
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern)
- throws-pattern?)
+throws-pattern?)
```
-- 除了返回类型模式,名字模式和参数模式以外,所有的部分都是可选的;
-- `*`,它代表了匹配任意的返回类型;
-- `()` 匹配了一个不接受任何参数的方法, 而 `(..)` 匹配了一个接受任意数量参数的方法(零或者更多)。 模式 `(*)` 匹配了一个接受一个任何类型的参数的方法。 模式 `(*,String)` 匹配了一个接受两个参数的方法,第一个可以是任意类型,第二个则必须是 String 类型。
+- 除了返回类型模式,名字模式和参数模式以外,所有的部分都是可选的。
+- `*` 代表了匹配任意的返回类型。
+- `()` 匹配一个不接受任何参数的方法, `(..)` 匹配一个接受任意数量参数的方法(零或者更多)。 `(*)` 匹配一个接受任意类型的参数的方法。 模式 `(*,String)` 匹配了一个接受两个参数的方法,第一个可以是任意类型,第二个则必须是 String 类型。
-下面给出一些常见切入点表达式的例子。
+下面为一些常见切入点表达式:
- 任意公共方法的执行:
@@ -195,25 +200,25 @@ execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-patter
execution(public * *(..))
```
-- 任何一个以“set”开始的方法的执行:
+- 任何一个以 `set` 开头的方法的执行:
```java
execution(* set*(..))
```
-- `AccountService` 接口的任意方法的执行:
+- `AccountService` 接口上任意方法的执行:
```java
execution(* com.xyz.service.AccountService.*(..))
```
-- 定义在 service 包里的任意方法的执行:
+- 定义在 service 包里任意方法的执行:
```java
execution(* com.xyz.service.*.*(..))
```
-- 定义在 service 包或者子包里的任意方法的执行:
+- 定义在 service 包或者子包里任意方法的执行:
```java
execution(* com.xyz.service..*.*(..))
diff --git a/spring/spring-druid-mybatis-annotation/README.md b/spring/spring-druid-mybatis-annotation/README.md
index b8ec2dc..8715021 100644
--- a/spring/spring-druid-mybatis-annotation/README.md
+++ b/spring/spring-druid-mybatis-annotation/README.md
@@ -1,23 +1,23 @@
-# spring +druid+ mybatis(注解方式)
-
-## 目录
- 1、创建maven工程,除了Spring基本依赖外,还需要导入mybatis和druid的相关依赖
- 2、新建 DispatcherServletInitializer.java继承自AbstractAnnotationConfigDispatcherServletInitializer,等价于我们在web.xml中配置的前端控制器
- 3、基于servlet 3.0的支持,可以采用注解的方式注册druid的servlet和filter
- 4、在resources文件夹下新建数据库配置文件mysql.properties、oracle.properties
- 5、在新建数据库配置映射类DataSourceConfig.java
- 6、新建ServletConfig.java,进行数据库相关配置
- 7、新建mybtais 配置文件,按需要进行额外参数配置, 更多settings配置项可以参考[官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html)
- 8、新建查询接口及其对应的mapper文件
- 9、新建测试controller进行测试
- 10、druid 监控页面访问地址http://localhost:8080/druid/index.html
-## 正文
+# Spring +Druid+ Mybatis(注解方式)
+
### 项目目录结构
+#### 1. 导入依赖
-#### 1、创建maven工程,除了Spring基本依赖外,还需要导入mybatis和druid的相关依赖
+创建 maven 工程,除了 Spring 的基本依赖外,还需要导入 Mybatis 和 Druid 的相关依赖:
```xml
@@ -55,7 +55,9 @@
```
-#### 2、新建 DispatcherServletInitializer.java继承自AbstractAnnotationConfigDispatcherServletInitializer,等价于我们在web.xml中配置的前端控制器
+#### 2. 配置前端控制器
+
+新建 DispatcherServletInitializer 继承自 AbstractAnnotationConfigDispatcherServletInitializer,等价于在 web.xml 方式中配置的前端控制器:
```java
public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@@ -74,15 +76,11 @@ public class DispatcherServletInitializer extends AbstractAnnotationConfigDispat
}
```
-#### 3、基于servlet 3.0的支持,可以采用注解的方式注册druid的servlet和filter
+#### 3. 配置 Druid 监控
- 注:关于 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 小节 注解和可插拔性**
+基于 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 小节 注解和可插拔性**
```java
-/**
- * @author : heibaiying
- * @description : 配置监控页面用户名密码
- */
@WebServlet(urlPatterns = "/druid/*",
initParams={
@WebInitParam(name="resetEnable",value="true"),
@@ -95,11 +93,6 @@ public class DruidStatViewServlet extends StatViewServlet {
```
```java
-
-/**
- * @author : heibaiying
- * @description : WebStatFilter 用于采集 web-jdbc 关联监控的数据
- */
@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*",
initParams={
@WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源
@@ -108,10 +101,11 @@ public class DruidStatViewServlet extends StatViewServlet {
public class DruidStatFilter extends WebStatFilter {
}
-
```
-#### 4、在resources文件夹下新建数据库配置文件mysql.properties、oracle.properties
+#### 4. 数据库配置
+
+在 resources 文件夹下新建数据库配置文件及其映射类:
```properties
# mysql 数据库配置
@@ -129,8 +123,6 @@ oracle.username=用户名
oracle.password=密码
```
-#### 5、在新建数据库配置映射类DataSourceConfig.java
-
```java
@Configuration
@PropertySource(value = "classpath:mysql.properties")
@@ -147,15 +139,13 @@ public class DataSourceConfig {
private String password;
}
-
```
-#### 6、新建ServletConfig.java,进行数据库相关配置
+#### 5. Druid 连接池配置
+
+新建 ServletConfig,进行数据库相关配置:
```java
-/**
- * @author : heibaiying
- */
@Configuration
@EnableTransactionManagement // 开启声明式事务处理 等价于 xml 中
@EnableWebMvc
@@ -249,12 +239,12 @@ public class ServletConfig implements WebMvcConfigurer {
manager.setDataSource(dataSource);
return manager;
}
-
}
-
```
-#### 7、新建mybtais 配置文件,按需要进行额外参数配置, 更多settings配置项可以参考[官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html)
+#### 6. MyBatis 配置
+
+新建 mybtais 配置文件,按照需求配置额外参数, 更多 settings 配置项可以参考 [官方文档](
```xml
@@ -272,12 +262,11 @@ public class ServletConfig implements WebMvcConfigurer {
-
-
-
```
-#### 8、新建查询接口及其对应的mapper文件
+#### 7. 数据查询
+
+新建查询接口及其实现类,以下示例分别查询的是 MySQL 和 Oracle 中的字典表:
```java
public interface MysqlDao {
@@ -324,7 +313,9 @@ public interface OracleDao {
```
-#### 9、新建测试controller进行测试
+#### 8. 测试查询
+
+新建测试类进行测试:
```java
@RestController
@@ -338,7 +329,6 @@ public class MysqlController {
return mysqlDao.queryById(id).get(0).toString();
}
}
-
```
```java
@@ -353,10 +343,11 @@ public class OracleController {
return oracleDao.queryById(id).get(0).toString();
}
}
-
```
-#### 10、druid 监控页面访问地址http://localhost:8080/druid/index.html
+#### 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 4f807f9..3d4beaa 100644
--- a/spring/spring-druid-mybatis/README.md
+++ b/spring/spring-druid-mybatis/README.md
@@ -1,21 +1,24 @@
-# spring +druid+ mybatis(xml配置方式)
-
-## 目录
- 1、创建maven工程,除了Spring基本依赖外,还需要导入mybatis和druid的相关依赖
- 2、在web.xml 中配置spring前端控制器、druid监控台servlet和filter
- 3、在resources文件夹下新建数据库配置文件jdbc.properties
- 4、在resources文件夹下创建springApplication.xml 配置文件和druid.xml配置文件
- 5、新建mybtais 配置文件,按需要进行额外配置,更多settings配置项可以参考[官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html)
- 6、新建查询接口及其对应的mapper文件
- 7、新建测试controller进行测试
- 8、druid 监控页面访问地址http://localhost:8080/druid/index.html
-## 正文
+# Spring +Druid+ Mybatis(XML 配置方式)
+
### 项目目录结构
-#### 1、创建maven工程,除了Spring基本依赖外,还需要导入mybatis和druid的相关依赖
+
+#### 1. 导入依赖
+
+创建 maven 工程,除了 Spring 的基本依赖外,还需要导入 Mybatis 和 Druid 的相关依赖:
```xml
@@ -53,7 +56,9 @@
```
-#### 2、在web.xml 中配置spring前端控制器、druid监控台servlet和filter
+#### 2. web.xml 配置
+
+在 `web.xml` 中配置 Spring 的前端控制器以及 Druid 的 Web 监控台,用于获取数据库的相关监控信息:
```xml
@@ -118,11 +123,12 @@
/*
-
```
-#### 3、在resources文件夹下新建数据库配置文件jdbc.properties
+#### 3. 数据库配置
+
+在 resources 文件夹下新建数据库配置文件 `jdbc.properties`:
```properties
# mysql 数据库配置
@@ -136,7 +142,9 @@ oracle.username=用户名
oracle.password=密码
```
-#### 4、在resources文件夹下创建springApplication.xml 配置文件和druid.xml配置文件
+#### 4. Druid 连接池配置
+
+在 resources 文件夹下创建 `springApplication.xml` 配置文件和 `druid.xml` 配置文件:
```xml
@@ -145,7 +153,7 @@ oracle.password=密码
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
@@ -185,7 +193,6 @@ oracle.password=密码
-
```
@@ -195,8 +202,7 @@ oracle.password=密码
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
-
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
@@ -245,11 +251,12 @@ oracle.password=密码
-
```
-#### 5、新建mybtais 配置文件,按需要进行额外配置,更多settings配置项可以参考[官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html)
+#### 5. MyBatis 配置
+
+新建 mybtais 配置文件,按照需求配置额外参数, 更多 settings 配置项可以参考 [官方文档](http://www.mybatis.org/mybatis-3/zh/configuration.html)
```xml
@@ -267,12 +274,11 @@ oracle.password=密码
-
-
-
```
-#### 6、新建查询接口及其对应的mapper文件
+#### 6. 数据查询
+
+新建查询接口及其实现类,以下示例分别查询的是 MySQL 和 Oracle 中的字典表:
```java
public interface MysqlDao {
@@ -319,25 +325,11 @@ public interface OracleDao {
```
-#### 7、新建测试controller进行测试
+#### 7. 测试查询
+
+新建测试类进行测试:
```java
-package com.heibaiying.controller;
-
-import com.heibaiying.bean.Relation;
-import com.heibaiying.dao.MysqlDao;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-/**
- * @author : heibaiying
- * @description :
- */
-
@RestController
public class MysqlController {
@@ -349,23 +341,9 @@ public class MysqlController {
return mysqlDao.queryById(id).get(0).toString();
}
}
-
```
```java
-package com.heibaiying.controller;
-
-import com.heibaiying.dao.OracleDao;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author : heibaiying
- * @description :
- */
-
@RestController
public class OracleController {
@@ -377,9 +355,10 @@ public class OracleController {
return oracleDao.queryById(id).get(0).toString();
}
}
-
```
-#### 8、druid 监控页面访问地址http://localhost:8080/druid/index.html
+#### 8. Druid 监控台
+
+Druid Web 页面访问地址为:http://localhost:8080/druid/index.html,可以登录后查看数据库相关监控数据:

diff --git a/spring/spring-dubbo-annotation/README.md b/spring/spring-dubbo-annotation/README.md
index 71c1ef1..e586953 100644
--- a/spring/spring-dubbo-annotation/README.md
+++ b/spring/spring-dubbo-annotation/README.md
@@ -1,39 +1,34 @@
-# spring 整合 dubbo(注解方式)
+# Spring 整合 Dubbo(注解方式)
-## 目录
-一、 项目结构说明
+
+## 一、 项目结构
-## 一、 项目结构说明
+按照 Dubbo 官方文档推荐的服务最佳化方案,建议将服务接口、服务模型、服务异常等均放在单独的 API 包中,所以项目采用 maven 多模块的构建方式,在 spring-dubbo 下构建三个子模块:
-1.1 按照 dubbo 文档推荐的服务最佳实践,建议将服务接口、服务模型、服务异常等均放在 API 包中,所以项目采用 maven 多模块的构建方式,在 spring-dubbo-annotation 下构建三个子模块:
+- **dubbo-common**:公共模块,用于存放公共的接口和 bean,被 dubbo-provider 和 dubbo-provider 所引用;
+- **dubbo-provider** :服务的提供者,提供商品的查询服务;
+- **dubbo-provider** :是服务的消费者,调用 provider 提供的查询服务。
-1. dubbo-ano-common 是公共模块,用于存放公共的接口和 bean,被 dubbo-ano-provider 和 dubbo-ano-provider 在 pom.xml 中引用;
-2. dubbo-ano-provider 是服务的提供者,提供商品的查询服务;
-3. dubbo-ano-provider 是服务的消费者,调用 provider 提供的查询服务。
-
-1.2 本项目 dubbo 的搭建采用 zookeeper 作为注册中心, 关于 zookeeper 的安装和基本操作可以参见我的手记[Zookeeper 基础命令与 Java 客户端](https://github.com/heibaiying/LearningNotes/blob/master/notes/%E4%B8%AD%E9%97%B4%E4%BB%B6/ZooKeeper/ZooKeeper%E9%9B%86%E7%BE%A4%E6%90%AD%E5%BB%BA%E4%B8%8EJava%E5%AE%A2%E6%88%B7%E7%AB%AF.md)
+另外,本项目 Dubbo 的搭建采用 ZooKeeper 作为注册中心。
-
-
## 二、项目依赖
-**在父工程的项目中统一导入依赖 dubbo 依赖的的 jar 包**
-
-这里需要注意的是 ZooKeeper 3.5.x 和 ZooKeeper 3.4.x 是存在不兼容的情况 详见官网解释[ZooKeeper Version Compatibility](https://curator.apache.org/zk-compatibility.html), zookeeper 3.5 目前是 beta 版本,所以 zookeeper 我选择的版本是 zookeeper-3.4.9 作为服务端。但默认情况下 curator-framework 自动引用的最新的 3.5 的版本客户端,会出现 KeeperException$UnimplementedException 异常
+在父工程的项目中统一导入依赖 Dubbo 的依赖:
```xml
@@ -59,20 +54,18 @@
```
+上面之所以要排除 curator-framework 中的 zookeeper,然后再次进行引入,是因为默认情况下 curator-framework 自动引用的最新的 3.5.x 的 zookeeper,但我本地安装是 3.4.x 的 zookeeper (因为我安装时候 zookeeper 3.5 还是 beta 版本),此时会出现 KeeperException$UnimplementedException 异常。因为 ZooKeeper 3.5.x 和 ZooKeeper 3.4.x 存在不兼容的情况,详见官方说明 [ZooKeeper Version Compatibility](https://curator.apache.org/zk-compatibility.html) 。
-
-## 三、公共模块(dubbo-ano-common)
+## 三、公共模块
- api 下为公共的调用接口;
- bean 下为公共的实体类。
-
-## 四、 服务提供者(dubbo-ano-provider)
+## 四、 服务提供者
-
-#### 4.1 提供方配置
+### 4.1 提供者配置
```java
@Configuration
@@ -112,26 +105,13 @@ public class DubboConfiguration {
}
```
-#### 4.2 使用注解@Service暴露服务
+### 4.2 暴露服务
-需要注意的是这里的@Service 注解不是 spring 的注解,而是 dubbo 的注解 com.alibaba.dubbo.config.annotation.Service
+使用注解 @Service 暴露服务,需要注意的是这里的 @Service 注解不是 spring 的注解,而是 dubbo 的注解,完整路径为:com.alibaba.dubbo.config.annotation.Service :
```java
-package com.heibaiying.service;
-
import com.alibaba.dubbo.config.annotation.Service;
-import com.heibaiying.api.IProductService;
-import com.heibaiying.bean.Product;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author : heibaiying
- * @description : 产品提供接口实现类
- */
@Service(timeout = 5000)
public class ProductService implements IProductService {
@@ -160,11 +140,10 @@ public class ProductService implements IProductService {
-## 五、服务消费者(dubbo-ano-consumer)
+## 五、服务消费者
-
-#### 1.消费方的配置
+### 5.1 消费者配置
```java
@Configuration
@@ -206,20 +185,12 @@ public class DubboConfiguration {
}
```
-#### 2.使用注解@Reference引用远程服务
+### 5.2 调用远程服务
+
+使用注解 @Reference 引用远程服务:
```java
-package com.heibaiying.controller;
-
import com.alibaba.dubbo.config.annotation.Reference;
-import com.heibaiying.api.IProductService;
-import com.heibaiying.bean.Product;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import java.util.List;
@Controller
@RequestMapping("sell")
@@ -246,73 +217,17 @@ public class SellController {
```
-## 六、项目构建的说明
+## 六、项目构建
-因为在项目中,consumer 和 provider 模块均依赖公共模块,所以在构建 consumer 和 provider 项目前需要将 common 模块安装到本地仓库,**依次**对**父工程**和**common 模块**执行:
+在项目中,consumer 和 provider 模块均依赖公共模块,所以在构建 consumer 和 provider 模块前需要将 common 模块安装到本地仓库,依次对 父工程 和 common 模块执行以下命令:
```shell
mvn install -Dmaven.test.skip = true
```
-consumer 中 pom.xml 如下
+## 七、Dubbo 控制台
-```xml
-
-
-
- spring-dubbo-annotation
- com.heibaiying
- 1.0-SNAPSHOT
-
- 4.0.0
-
- dubbo-ano-consumer
-
-
-
- com.heibaiying
- dubbo-ano-common
- 1.0-SNAPSHOT
- compile
-
-
-
-
-```
-
-provider 中 pom.xml 如下
-
-```xml
-
-
-
- spring-dubbo-annotation
- com.heibaiying
- 1.0-SNAPSHOT
-
- 4.0.0
-
- dubbo-ano-provider
-
-
-
- com.heibaiying
- dubbo-ano-common
- 1.0-SNAPSHOT
- compile
-
-
-
-
-```
-
-## 七、关于dubbo新版本管理控制台的安装说明
-
-安装:
+Dubbo 新版本管理控制台的安装步骤如下:
```sh
git clone https://github.com/apache/incubator-dubbo-ops.git /var/tmp/dubbo-ops
@@ -322,21 +237,22 @@ mvn clean package
配置:
-```sh
-配置文件为:
+```properties
+# 配置文件为:
dubbo-admin-backend/src/main/resources/application.properties
-主要的配置有 默认的配置就是 127.0.0.1:2181:
+
+# 可以在其中修改zookeeper的地址
dubbo.registry.address=zookeeper://127.0.0.1:2181
```
-启动:
+启动:
```sh
mvn --projects dubbo-admin-backend spring-boot:run
```
-访问:
+访问:
-```
+```shell
http://127.0.0.1:8080
```
diff --git a/spring/spring-dubbo/README.md b/spring/spring-dubbo/README.md
index f1ed719..071e97f 100644
--- a/spring/spring-dubbo/README.md
+++ b/spring/spring-dubbo/README.md
@@ -1,39 +1,35 @@
-# spring 整合 dubbo(xml配置方式)
+# Spring 整合 Dubbo(XML 配置方式)
-## 目录
-一、 项目结构说明
+
+## 一、 项目结构
-## 一、 项目结构说明
+按照 Dubbo 官方文档推荐的服务最佳化方案,建议将服务接口、服务模型、服务异常等均放在单独的 API 包中,所以项目采用 maven 多模块的构建方式,在 spring-dubbo 下构建三个子模块:
-1.1 按照 dubbo 文档推荐的服务最佳实践,建议将服务接口、服务模型、服务异常等均放在 API 包中,所以项目采用 maven 多模块的构建方式,在 spring-dubbo 下构建三个子模块:
+- **dubbo-common**:公共模块,用于存放公共的接口和 bean,被 dubbo-provider 和 dubbo-provider 所引用;
+- **dubbo-provider** :服务的提供者,提供商品的查询服务;
+- **dubbo-provider** :是服务的消费者,调用 provider 提供的查询服务。
-1. dubbo-common 是公共模块,用于存放公共的接口和 bean,被 dubbo-provider 和 dubbo-provider 在 pom.xml 中引用;
-2. dubbo-provider 是服务的提供者,提供商品的查询服务;
-3. dubbo-provider 是服务的消费者,调用 provider 提供的查询服务。
-
-1.2 本项目 dubbo 的搭建采用 zookeeper 作为注册中心, 关于 zookeeper 的安装和基本操作可以参见我的手记[Zookeeper 基础命令与 Java 客户端](https://github.com/heibaiying/LearningNotes/blob/master/notes/%E4%B8%AD%E9%97%B4%E4%BB%B6/ZooKeeper/ZooKeeper%E9%9B%86%E7%BE%A4%E6%90%AD%E5%BB%BA%E4%B8%8EJava%E5%AE%A2%E6%88%B7%E7%AB%AF.md)
+另外,本项目 Dubbo 的搭建采用 ZooKeeper 作为注册中心。
-
## 二、项目依赖
-**在父工程的项目中统一导入依赖 dubbo 依赖的的 jar 包**
-
-这里需要注意的是 ZooKeeper 3.5.x 和 ZooKeeper 3.4.x 是存在不兼容的情况 详见官网解释[ZooKeeper Version Compatibility](https://curator.apache.org/zk-compatibility.html), zookeeper 3.5 目前是 beta 版本,所以 zookeeper 我选择的版本是 zookeeper-3.4.9 作为服务端。但默认情况下 curator-framework 自动引用的最新的 3.5 的版本客户端,会出现 KeeperException$UnimplementedException 异常
+在父工程的项目中统一导入依赖 Dubbo 的依赖:
```xml
@@ -59,28 +55,22 @@
```
+上面之所以要排除 curator-framework 中的 zookeeper,然后再次进行引入,是因为默认情况下 curator-framework 自动引用的最新的 3.5.x 的 zookeeper,但我本地安装是 3.4.x 的 zookeeper (因为我安装时候 zookeeper 3.5 还是 beta 版本),此时会出现 KeeperException$UnimplementedException 异常。因为 ZooKeeper 3.5.x 和 ZooKeeper 3.4.x 存在不兼容的情况,详见官方说明 [ZooKeeper Version Compatibility](https://curator.apache.org/zk-compatibility.html) 。
-
-## 三、公共模块(dubbo-common)
+## 三、公共模块
- api 下为公共的调用接口;
- bean 下为公共的实体类。
-
-## 四、 服务提供者(dubbo-provider)
+## 四、 服务提供者
+### 4.1 开发服务
-#### 4.1 productService是服务的提供者( 商品数据用模拟数据展示)
-
-注:这里实现的接口 IProductService 来源于公共模块
+productService 是服务的提供者,其实现的接口 IProductService 来源于公共模块,这里商品数据用模拟数据展示:
```java
-/**
- * @author : heibaiying
- * @description : 产品提供接口实现类
- */
@Service
public class ProductService implements IProductService {
@@ -108,7 +98,9 @@ public class ProductService implements IProductService {
}
```
-#### 4.2 在dubbo.xml暴露服务
+### 4.2 暴露服务
+
+在 `dubbo.xml` 中暴露服务:
```xml
@@ -137,11 +129,12 @@ public class ProductService implements IProductService {
```
-## 五、服务消费者(dubbo-consumer)
+## 五、服务消费者
+### 5.1 调用服务
-#### 1.在dubbo.xml调用远程的服务
+在 `dubbo.xml` 中调用远程的服务:
```xml
@@ -172,7 +165,7 @@ public class ProductService implements IProductService {
```
-#### 2.消费服务
+### 5.2 消费服务
```java
@Controller
@@ -198,73 +191,17 @@ public class SellController {
}
```
-## 六、项目构建的说明
+## 六、项目构建
-因为在项目中,consumer 和 provider 模块均依赖公共模块,所以在构建 consumer 和 provider 项目前需要将 common 模块安装到本地仓库,**依次**对**父工程**和**common 模块**执行:
+在项目中,consumer 和 provider 模块均依赖公共模块,所以在构建 consumer 和 provider 模块前需要将 common 模块安装到本地仓库,依次对 父工程 和 common 模块执行以下命令:
```shell
mvn install -Dmaven.test.skip = true
```
-consumer 中 pom.xml 如下
+## 七、Dubbo 控制台
-```xml
-
-
-
- spring-dubbo
- com.heibaiying
- 1.0-SNAPSHOT
-
- 4.0.0
-
- dubbo-consumer
-
-
-
- com.heibaiying
- dubbo-common
- 1.0-SNAPSHOT
- compile
-
-
-
-
-```
-
-provider 中 pom.xml 如下
-
-```xml
-
-
-
- spring-dubbo
- com.heibaiying
- 1.0-SNAPSHOT
-
- 4.0.0
-
- dubbo-provider
-
-
-
- com.heibaiying
- dubbo-common
- 1.0-SNAPSHOT
- compile
-
-
-
-
-```
-
-## 七、关于dubbo新版本管理控制台的安装说明
-
-安装:
+Dubbo 新版本管理控制台的安装步骤如下:
```sh
git clone https://github.com/apache/incubator-dubbo-ops.git /var/tmp/dubbo-ops
@@ -274,21 +211,22 @@ mvn clean package
配置:
-```sh
-配置文件为:
+```properties
+# 配置文件为:
dubbo-admin-backend/src/main/resources/application.properties
-主要的配置有 默认的配置就是 127.0.0.1:2181:
+
+# 可以在其中修改zookeeper的地址
dubbo.registry.address=zookeeper://127.0.0.1:2181
```
-启动:
+启动:
```sh
mvn --projects dubbo-admin-backend spring-boot:run
```
-访问:
+访问:
-```
+```shell
http://127.0.0.1:8080
```
diff --git a/spring/spring-email-annotation/README.md b/spring/spring-email-annotation/README.md
index 55f1edf..aef0ef7 100644
--- a/spring/spring-email-annotation/README.md
+++ b/spring/spring-email-annotation/README.md
@@ -1,33 +1,33 @@
-# spring 邮件发送(xml配置方式)
+# Spring 邮件发送(注解方式)
-## 目录
-一、说明
- 1.1 项目结构说明
- 1.2 依赖说明
-二、spring email
+
+## 一、项目说明
-## 一、说明
+### 1.1 项目结构
-### 1.1 项目结构说明
+- 邮件的发送配置类为 com.heibaiying.config 下 EmailConfig;
-1. 邮件发送配置类为 com.heibaiying.config 下 EmailConfig.java;
-2. 简单邮件发送、附件邮件发送、内嵌资源邮件发送、模板邮件发送的方法封装在 SpringMail 类中;
-3. 项目以单元测试的方法进行测试,测试类为 SendEmail。
+- 简单邮件发送、附件邮件发送、内嵌资源邮件发送、模板邮件发送的方法封装在 SpringMail 类中;
+- 项目以单元测试的方法进行测试,测试类为 SendEmail。
+
+### 1.2 基本依赖
-### 1.2 依赖说明
-
-除了 spring 的基本依赖外,需要导入邮件发送的支持包 spring-context-support
+除了 Spring 的基本依赖外,需要导入邮件发送的支持包 spring-context-support:
```xml
@@ -47,16 +47,11 @@
-## 二、spring email
+## 二、Spring Email
-#### 2.1 邮件发送配置
+### 2.1 邮件发送配置
```java
-/**
- * @author : heibaiying
- * @description : 邮件发送配置类
- */
-
@Configuration
@ComponentScan(value = "com.heibaiying.email")
public class EmailConfig {
@@ -87,11 +82,10 @@ public class EmailConfig {
```
-#### 2.2 新建邮件发送基本类
+### 2.2 发送邮件
```java
/**
- * @author : heibaiying
* @description : 邮件发送基本类
*/
@Component
@@ -218,18 +212,12 @@ public class SpringMail {
System.err.println("发送邮件失败" + ex.getMessage());
}
}
-
}
-
```
-**关于模板邮件的说明:**
+- **关于模板邮件的说明:**
-- 模板引擎最主要的作用是,在对邮件格式有要求的时候,采用拼接字符串不够直观,所以采用模板引擎;
-
-- 这里我们使用的 beetl 模板引擎,原因是其性能优异,官网是介绍其性能 6 倍与 freemaker,并有完善的文档支持。当然大家也可以换成任何其他的模板引擎(freemarker,thymeleaf)
-
- 一个简单的模板 template.html 如下:
+ 通常邮件都有规范的格式要求,因此 Spring 支持使用任意模板引擎来配置模板。这里我们使用的 beetl 模板引擎,其性能比较优异,官网是介绍其性能 6 倍于 freemaker,当然也可以换成其他模板引擎( 如 freemarker,thymeleaf)。示例如下:
```html
@@ -244,15 +232,9 @@ public class SpringMail {