diff --git a/README.md b/README.md
index 31647a8..ca0beb3 100644
--- a/README.md
+++ b/README.md
@@ -82,16 +82,12 @@ spring-cloud:Finchley.SR2
-## 4.分布式session和分布式事务
+## 4.spring分布式session和分布式事务
-| 描述 | sample | 官方文档 |
-| ---------------------------------------- | ---------------------------- | ------------------------------------------------------------ |
-| 分布式session解决方案(一) | spring session | [spring session](https://spring.io/projects/spring-session#learn) |
-| 分布式session 解决方案(二) | spring boot + spring session | |
-| 分布式session 解决方案(三) | memcached-session-manager | |
-| 分布式事务解决方案(一)——JPA | 待补充 | |
-| 分布式事务解决方案(二)——Spring事务同步 | 待补充 | |
-| 分布式事务解决方案(三)——链式事务 | 待补充 | |
+| sample | 描述 | 官方文档 |
+| ---------------------------- | -------------------------- | ------------------------------------------------------------ |
+| spring-session | spring 分布式 session | [spring session](https://spring.io/projects/spring-session#learn) |
+| spring boot + spring session | spring boot 分布式 session | [spring session](https://spring.io/projects/spring-session#learn) |
diff --git a/distributed solution/msm/pom.xml b/distributed solution/msm/pom.xml
new file mode 100644
index 0000000..b45a1b8
--- /dev/null
+++ b/distributed solution/msm/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+ war
+
+ com.heibaiying
+ msm
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 8
+ 8
+
+
+
+
+
+
+ 5.1.3.RELEASE
+
+
+
+
+ org.springframework
+ spring-context
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-beans
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-core
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-web
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-webmvc
+ ${spring-base-version}
+
+
+ javax.servlet
+ javax.servlet-api
+ 4.0.1
+ provided
+
+
+ org.projectlombok
+ lombok
+ 1.18.0
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/msm/src/main/java/com/heibaiying/bean/User.java b/distributed solution/msm/src/main/java/com/heibaiying/bean/User.java
new file mode 100644
index 0000000..16f41ed
--- /dev/null
+++ b/distributed solution/msm/src/main/java/com/heibaiying/bean/User.java
@@ -0,0 +1,17 @@
+package com.heibaiying.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author : heibaiying
+ */
+@Data
+public class User implements Serializable {
+
+ private long userId;
+ private String username;
+ private String password;
+
+}
diff --git a/distributed solution/msm/src/main/java/com/heibaiying/controller/LoginController.java b/distributed solution/msm/src/main/java/com/heibaiying/controller/LoginController.java
new file mode 100644
index 0000000..8a11c03
--- /dev/null
+++ b/distributed solution/msm/src/main/java/com/heibaiying/controller/LoginController.java
@@ -0,0 +1,38 @@
+package com.heibaiying.controller;
+
+import com.heibaiying.bean.User;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author : heibaiying
+ * @description : 登录
+ */
+@Controller
+public class LoginController {
+
+ @RequestMapping
+ public String index(){
+ return "index";
+ }
+
+ @RequestMapping("home")
+ public String home(){
+ return "home";
+ }
+
+ @PostMapping("login")
+ public String login(User user, HttpSession session, HttpServletRequest request, Model model){
+ // 随机生成用户id
+ user.setUserId(Math.round(Math.floor(Math.random() *10*1000)));
+ // 将用户信息保存到id中
+ session.setAttribute("USER",user);
+ return "redirect:home";
+ }
+
+}
diff --git a/distributed solution/msm/src/main/resources/springApplication.xml b/distributed solution/msm/src/main/resources/springApplication.xml
new file mode 100644
index 0000000..6b3fa23
--- /dev/null
+++ b/distributed solution/msm/src/main/resources/springApplication.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/msm/src/main/webapp/WEB-INF/jsp/home.jsp b/distributed solution/msm/src/main/webapp/WEB-INF/jsp/home.jsp
new file mode 100644
index 0000000..5a822db
--- /dev/null
+++ b/distributed solution/msm/src/main/webapp/WEB-INF/jsp/home.jsp
@@ -0,0 +1,11 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ 主页面
+
+
+ 服务器:<%=request.getServerName()+":"+request.getServerPort()%>
+ 登录用户: ${sessionScope.USER.username}
+ 用户编号: ${sessionScope.USER.userId}
+
+
\ No newline at end of file
diff --git a/distributed solution/msm/src/main/webapp/WEB-INF/jsp/index.jsp b/distributed solution/msm/src/main/webapp/WEB-INF/jsp/index.jsp
new file mode 100644
index 0000000..805223a
--- /dev/null
+++ b/distributed solution/msm/src/main/webapp/WEB-INF/jsp/index.jsp
@@ -0,0 +1,14 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ 登录页面
+
+
+服务器:<%=request.getServerName()+":"+request.getServerPort()%>
+
+
+
\ No newline at end of file
diff --git a/distributed solution/msm/src/main/webapp/WEB-INF/web.xml b/distributed solution/msm/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..ea02a7a
--- /dev/null
+++ b/distributed solution/msm/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+ springMvc
+ org.springframework.web.servlet.DispatcherServlet
+
+ contextConfigLocation
+ classpath:springApplication.xml
+
+ 1
+
+
+
+ springMvc
+ /
+
+
+
+
+ characterEncodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ encoding
+ UTF-8
+
+
+ forceEncoding
+ true
+
+
+
+ characterEncodingFilter
+ /*
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-boot-session/README.md b/distributed solution/spring-boot-session/README.md
new file mode 100644
index 0000000..9608867
--- /dev/null
+++ b/distributed solution/spring-boot-session/README.md
@@ -0,0 +1,152 @@
+# spring boot 实现分布式 session
+
+## 一、项目结构
+
+
+
+
+
+## 二、分布式session的配置
+
+#### 2.1 引入依赖
+
+```xml
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.springframework.session
+ spring-session-data-redis
+
+```
+
+#### 2.2 Redis配置
+
+```yaml
+spring:
+ redis:
+ host: 127.0.0.1
+ port: 6379
+ jedis:
+ pool:
+ # 连接池最大连接数,使用负值表示无限制。
+ max-active: 8
+ # 连接池最大阻塞等待时间,使用负值表示无限制。
+ max-wait: -1s
+ # 连接池最大空闲数,使用负值表示无限制。
+ max-idle: 8
+ # 连接池最小空闲连接,只有设置为正值时候才有效
+ min-idle: 1
+ timeout: 300ms
+ session:
+ # session 存储方式 支持redis、mongo、jdbc、hazelcast
+ store-type: redis
+
+# 如果是集群节点 采用如下配置指定节点
+#spring.redis.cluster.nodes
+
+```
+
+有两点需要特别说明:
+
+1. spring-session 不仅提供了redis作为公共session存储的方案,同时也支持jdbc、mongodb、Hazelcast等作为公共session的存储,可以用session.store-type 指定;
+2. 对于redis 存储方案而言,官方也提供了不止一种整合方式,这里我们选取的整合方案是jedis客户端作为连接,当然也可以使用Lettuce作为客户端连接。
+
+#### 2.3 启动类上添加@EnableRedisHttpSession 注解开启 spring-session-redis 整合方案的自动配置
+
+```java
+@SpringBootApplication
+@EnableRedisHttpSession(maxInactiveIntervalInSeconds= 1800) //开启redis session支持,并配置session过期时间
+public class SpringBootSessionApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootSessionApplication.class, args);
+ }
+
+}
+```
+
+
+
+## 三、验证分布式session
+
+#### 3.1 创建测试controller和测试页面
+
+```java
+@Controller
+public class LoginController {
+
+ @RequestMapping
+ public String index() {
+ return "index";
+ }
+
+ @RequestMapping("home")
+ public String home() {
+ return "home";
+ }
+
+ @PostMapping("login")
+ public String login(User user, HttpSession session) {
+ // 随机生成用户id
+ user.setUserId(Math.round(Math.floor(Math.random() * 10 * 1000)));
+ // 将用户信息保存到id中
+ session.setAttribute("USER", user);
+ return "home";
+ }
+
+}
+```
+
+登录页面index.ftl:
+
+```jsp
+
+
+
+ 登录页面
+
+
+
+
+
+```
+
+session 信息展示页面home.ftl:
+
+```jsp
+
+
+
+ 主页面
+
+
+ 登录用户: ${Session["USER"].username}
+ 用户编号: ${Session["USER"].userId}
+
+
+```
+
+#### 3.2 启动项目
+
+由于我们这里采用的是spring boot 的内置容器作为web容器,所以直接启动两个实例测试即可。
+
+应用1启动配置:
+
+
+
+应用2启动配置,需要用 `--server.port `指定不同的端口号:
+
+
+
+**测试结果:**
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-boot-session/pom.xml b/distributed solution/spring-boot-session/pom.xml
new file mode 100644
index 0000000..a2e25f5
--- /dev/null
+++ b/distributed solution/spring-boot-session/pom.xml
@@ -0,0 +1,60 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.2.RELEASE
+
+
+ com.heibaiying
+ spring-boot-session
+ 0.0.1-SNAPSHOT
+ spring-boot-session
+ spring session project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.springframework.boot
+ spring-boot-starter-freemarker
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.session
+ spring-session-data-redis
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/SpringBootSessionApplication.java b/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/SpringBootSessionApplication.java
new file mode 100644
index 0000000..d006c3a
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/SpringBootSessionApplication.java
@@ -0,0 +1,16 @@
+package com.heibaiying.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
+
+@SpringBootApplication
+@EnableRedisHttpSession(maxInactiveIntervalInSeconds= 1800) //开启redis session支持,并配置session过期时间
+public class SpringBootSessionApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootSessionApplication.class, args);
+ }
+
+}
+
diff --git a/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/bean/User.java b/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/bean/User.java
new file mode 100644
index 0000000..a468fe4
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/bean/User.java
@@ -0,0 +1,17 @@
+package com.heibaiying.springboot.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author : heibaiying
+ */
+@Data
+public class User implements Serializable {
+
+ private long userId;
+ private String username;
+ private String password;
+
+}
diff --git a/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/controller/LoginController.java b/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/controller/LoginController.java
new file mode 100644
index 0000000..dc5069d
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/main/java/com/heibaiying/springboot/controller/LoginController.java
@@ -0,0 +1,37 @@
+package com.heibaiying.springboot.controller;
+
+
+import com.heibaiying.springboot.bean.User;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author : heibaiying
+ * @description : 登录
+ */
+@Controller
+public class LoginController {
+
+ @RequestMapping
+ public String index() {
+ return "index";
+ }
+
+ @RequestMapping("home")
+ public String home() {
+ return "home";
+ }
+
+ @PostMapping("login")
+ public String login(User user, HttpSession session) {
+ // 随机生成用户id
+ user.setUserId(Math.round(Math.floor(Math.random() * 10 * 1000)));
+ // 将用户信息保存到id中
+ session.setAttribute("USER", user);
+ return "home";
+ }
+
+}
diff --git a/distributed solution/spring-boot-session/src/main/resources/application.yml b/distributed solution/spring-boot-session/src/main/resources/application.yml
new file mode 100644
index 0000000..7d7c7c6
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/main/resources/application.yml
@@ -0,0 +1,21 @@
+spring:
+ redis:
+ host: 127.0.0.1
+ port: 6379
+ jedis:
+ pool:
+ # 连接池最大连接数,使用负值表示无限制。
+ max-active: 8
+ # 连接池最大阻塞等待时间,使用负值表示无限制。
+ max-wait: -1s
+ # 连接池最大空闲数,使用负值表示无限制。
+ max-idle: 8
+ # 连接池最小空闲连接,只有设置为正值时候才有效
+ min-idle: 1
+ timeout: 300ms
+ session:
+ # session 存储方式 支持redis、mongo、jdbc、hazelcast
+ store-type: redis
+
+# 如果是集群节点 采用如下配置指定节点
+#spring.redis.cluster.nodes
diff --git a/distributed solution/spring-boot-session/src/main/resources/templates/home.ftl b/distributed solution/spring-boot-session/src/main/resources/templates/home.ftl
new file mode 100644
index 0000000..4b08772
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/main/resources/templates/home.ftl
@@ -0,0 +1,10 @@
+
+
+
+ 主页面
+
+
+ 登录用户: ${Session["USER"].username}
+ 用户编号: ${Session["USER"].userId}
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-boot-session/src/main/resources/templates/index.ftl b/distributed solution/spring-boot-session/src/main/resources/templates/index.ftl
new file mode 100644
index 0000000..cde4d61
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/main/resources/templates/index.ftl
@@ -0,0 +1,13 @@
+
+
+
+ 登录页面
+
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-boot-session/src/test/java/com/heibaiying/springboot/SpringBootSessionApplicationTests.java b/distributed solution/spring-boot-session/src/test/java/com/heibaiying/springboot/SpringBootSessionApplicationTests.java
new file mode 100644
index 0000000..479c4e4
--- /dev/null
+++ b/distributed solution/spring-boot-session/src/test/java/com/heibaiying/springboot/SpringBootSessionApplicationTests.java
@@ -0,0 +1,17 @@
+package com.heibaiying.springboot;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringBootSessionApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
+
diff --git a/distributed solution/spring-session/README.md b/distributed solution/spring-session/README.md
new file mode 100644
index 0000000..5470316
--- /dev/null
+++ b/distributed solution/spring-session/README.md
@@ -0,0 +1,189 @@
+# spring session 实现分布式 session
+
+## 一、项目结构
+
+分布式session 主要配置文件为spring-session.xml和web.xml,其他的配置为标准的web工程的配置。
+
+
+
+## 二、分布式session的配置
+
+#### 2.1 引入依赖
+
+```xml
+
+
+ org.springframework.data
+ spring-data-redis
+ 2.1.3.RELEASE
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+ org.springframework.session
+ spring-session-data-redis
+ 2.1.3.RELEASE
+
+```
+
+#### 2.2 在web.xml中配置session拦截器
+
+```xml
+
+
+ springSessionRepositoryFilter
+ org.springframework.web.filter.DelegatingFilterProxy
+
+
+ springSessionRepositoryFilter
+ /*
+
+
+```
+
+#### 2.3 创建配置文件spring- session.xml,配置redis连接
+
+有两点需要特别说明:
+
+1. spring-session 不仅提供了redis作为公共session存储的方案,同时也支持jdbc、mongodb、Hazelcast等作为公共session的存储;
+2. 对于redis 存储方案而言,官方也提供了不止一种整合方式,这里我们选取的整合方案是jedis客户端作为连接,当然也可以使用Lettuce作为客户端连接。
+
+```xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+## 三、验证分布式session
+
+#### 3.1 创建测试controller和测试页面
+
+```java
+@Controller
+public class LoginController {
+
+ @RequestMapping
+ public String index(){
+ return "index";
+ }
+
+ @RequestMapping("home")
+ public String home(){
+ return "home";
+ }
+
+ @PostMapping("login")
+ public String login(User user, HttpSession session, HttpServletRequest request, Model model){
+ // 随机生成用户id
+ user.setUserId(Math.round(Math.floor(Math.random() *10*1000)));
+ // 将用户信息保存到id中
+ session.setAttribute("USER",user);
+ return "redirect:home";
+ }
+
+}
+```
+
+登录页面:
+
+```jsp
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ 登录页面
+
+
+服务器:<%=request.getServerName()+":"+request.getServerPort()%>
+
+
+
+```
+
+session 信息展示页面(home.jsp):
+
+```jsp
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ 主页面
+
+
+ 服务器:<%=request.getServerName()+":"+request.getServerPort()%>
+ 登录用户: ${sessionScope.USER.username}
+ 用户编号: ${sessionScope.USER.userId}
+
+
+```
+
+#### 3.2 启动项目
+
+这里我们采用两个tomcat分别启动项目,在第一个项目index.jsp页面进行登录,第二个项目不登录,直接访问session展示页(home.jsp)
+
+tomcat 1 配置:
+
+
+
+tomcat 2 配置:
+
+
+
+**测试结果:**
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-session/pom.xml b/distributed solution/spring-session/pom.xml
new file mode 100644
index 0000000..1ac5fa9
--- /dev/null
+++ b/distributed solution/spring-session/pom.xml
@@ -0,0 +1,82 @@
+
+
+ 4.0.0
+
+ com.heibaiying
+ spring-session
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 8
+ 8
+
+
+
+
+
+
+ 5.1.3.RELEASE
+
+
+
+
+ org.springframework
+ spring-context
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-beans
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-core
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-web
+ ${spring-base-version}
+
+
+ org.springframework
+ spring-webmvc
+ ${spring-base-version}
+
+
+ javax.servlet
+ javax.servlet-api
+ 4.0.1
+ provided
+
+
+ org.projectlombok
+ lombok
+ 1.18.0
+
+
+
+ org.springframework.data
+ spring-data-redis
+ 2.1.3.RELEASE
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+ org.springframework.session
+ spring-session-data-redis
+ 2.1.3.RELEASE
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-session/src/main/java/com/heibaiying/bean/User.java b/distributed solution/spring-session/src/main/java/com/heibaiying/bean/User.java
new file mode 100644
index 0000000..16f41ed
--- /dev/null
+++ b/distributed solution/spring-session/src/main/java/com/heibaiying/bean/User.java
@@ -0,0 +1,17 @@
+package com.heibaiying.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author : heibaiying
+ */
+@Data
+public class User implements Serializable {
+
+ private long userId;
+ private String username;
+ private String password;
+
+}
diff --git a/distributed solution/spring-session/src/main/java/com/heibaiying/controller/LoginController.java b/distributed solution/spring-session/src/main/java/com/heibaiying/controller/LoginController.java
new file mode 100644
index 0000000..8a11c03
--- /dev/null
+++ b/distributed solution/spring-session/src/main/java/com/heibaiying/controller/LoginController.java
@@ -0,0 +1,38 @@
+package com.heibaiying.controller;
+
+import com.heibaiying.bean.User;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author : heibaiying
+ * @description : 登录
+ */
+@Controller
+public class LoginController {
+
+ @RequestMapping
+ public String index(){
+ return "index";
+ }
+
+ @RequestMapping("home")
+ public String home(){
+ return "home";
+ }
+
+ @PostMapping("login")
+ public String login(User user, HttpSession session, HttpServletRequest request, Model model){
+ // 随机生成用户id
+ user.setUserId(Math.round(Math.floor(Math.random() *10*1000)));
+ // 将用户信息保存到id中
+ session.setAttribute("USER",user);
+ return "redirect:home";
+ }
+
+}
diff --git a/distributed solution/spring-session/src/main/resources/redis.properties b/distributed solution/spring-session/src/main/resources/redis.properties
new file mode 100644
index 0000000..1a0357d
--- /dev/null
+++ b/distributed solution/spring-session/src/main/resources/redis.properties
@@ -0,0 +1,8 @@
+redis.host=127.0.0.1
+redis.port=6379
+# ӳʱʱ
+redis.timeout=2000
+#
+redis.maxIdle=8
+#
+redis.maxTotal=16
\ No newline at end of file
diff --git a/distributed solution/spring-session/src/main/resources/spring-session.xml b/distributed solution/spring-session/src/main/resources/spring-session.xml
new file mode 100644
index 0000000..b10cfe9
--- /dev/null
+++ b/distributed solution/spring-session/src/main/resources/spring-session.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-session/src/main/resources/springApplication.xml b/distributed solution/spring-session/src/main/resources/springApplication.xml
new file mode 100644
index 0000000..aafcb69
--- /dev/null
+++ b/distributed solution/spring-session/src/main/resources/springApplication.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-session/src/main/webapp/WEB-INF/jsp/home.jsp b/distributed solution/spring-session/src/main/webapp/WEB-INF/jsp/home.jsp
new file mode 100644
index 0000000..5a822db
--- /dev/null
+++ b/distributed solution/spring-session/src/main/webapp/WEB-INF/jsp/home.jsp
@@ -0,0 +1,11 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ 主页面
+
+
+ 服务器:<%=request.getServerName()+":"+request.getServerPort()%>
+ 登录用户: ${sessionScope.USER.username}
+ 用户编号: ${sessionScope.USER.userId}
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-session/src/main/webapp/WEB-INF/jsp/index.jsp b/distributed solution/spring-session/src/main/webapp/WEB-INF/jsp/index.jsp
new file mode 100644
index 0000000..805223a
--- /dev/null
+++ b/distributed solution/spring-session/src/main/webapp/WEB-INF/jsp/index.jsp
@@ -0,0 +1,14 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ 登录页面
+
+
+服务器:<%=request.getServerName()+":"+request.getServerPort()%>
+
+
+
\ No newline at end of file
diff --git a/distributed solution/spring-session/src/main/webapp/WEB-INF/web.xml b/distributed solution/spring-session/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..6cd84c6
--- /dev/null
+++ b/distributed solution/spring-session/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+ springMvc
+ org.springframework.web.servlet.DispatcherServlet
+
+ contextConfigLocation
+ classpath:springApplication.xml
+
+ 1
+
+
+
+ springMvc
+ /
+
+
+
+
+
+ springSessionRepositoryFilter
+ org.springframework.web.filter.DelegatingFilterProxy
+
+
+ springSessionRepositoryFilter
+ /*
+
+
+
+
+
+ characterEncodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ encoding
+ UTF-8
+
+
+ forceEncoding
+ true
+
+
+
+ characterEncodingFilter
+ /*
+
+
+
\ No newline at end of file
diff --git a/pictures/eureka-application.png b/pictures/eureka-application.png
new file mode 100644
index 0000000..b5d331a
Binary files /dev/null and b/pictures/eureka-application.png differ
diff --git a/pictures/eureka-server-client.png b/pictures/eureka-server-client.png
new file mode 100644
index 0000000..a932dcd
Binary files /dev/null and b/pictures/eureka-server-client.png differ
diff --git a/pictures/spring-boot-session-8080.png b/pictures/spring-boot-session-8080.png
new file mode 100644
index 0000000..0348960
Binary files /dev/null and b/pictures/spring-boot-session-8080.png differ
diff --git a/pictures/spring-boot-session-8090.png b/pictures/spring-boot-session-8090.png
new file mode 100644
index 0000000..fcd7e86
Binary files /dev/null and b/pictures/spring-boot-session-8090.png differ
diff --git a/pictures/spring-boot-session-app1.png b/pictures/spring-boot-session-app1.png
new file mode 100644
index 0000000..d628405
Binary files /dev/null and b/pictures/spring-boot-session-app1.png differ
diff --git a/pictures/spring-boot-session-app2.png b/pictures/spring-boot-session-app2.png
new file mode 100644
index 0000000..f050ebc
Binary files /dev/null and b/pictures/spring-boot-session-app2.png differ
diff --git a/pictures/spring-boot-session.png b/pictures/spring-boot-session.png
new file mode 100644
index 0000000..ec10117
Binary files /dev/null and b/pictures/spring-boot-session.png differ
diff --git a/pictures/spring-cloud-eureka-cluster.png b/pictures/spring-cloud-eureka-cluster.png
new file mode 100644
index 0000000..3fa546c
Binary files /dev/null and b/pictures/spring-cloud-eureka-cluster.png differ
diff --git a/pictures/spring-cloud-eureka.png b/pictures/spring-cloud-eureka.png
new file mode 100644
index 0000000..1663f73
Binary files /dev/null and b/pictures/spring-cloud-eureka.png differ
diff --git a/pictures/spring-session-8080.png b/pictures/spring-session-8080.png
new file mode 100644
index 0000000..974ffa8
Binary files /dev/null and b/pictures/spring-session-8080.png differ
diff --git a/pictures/spring-session-8090.png b/pictures/spring-session-8090.png
new file mode 100644
index 0000000..1f5e4ba
Binary files /dev/null and b/pictures/spring-session-8090.png differ
diff --git a/pictures/spring-session-tomcat01.png b/pictures/spring-session-tomcat01.png
new file mode 100644
index 0000000..4676a3d
Binary files /dev/null and b/pictures/spring-session-tomcat01.png differ
diff --git a/pictures/spring-session-tomcat02.png b/pictures/spring-session-tomcat02.png
new file mode 100644
index 0000000..369f6b0
Binary files /dev/null and b/pictures/spring-session-tomcat02.png differ
diff --git a/pictures/spring-session.png b/pictures/spring-session.png
new file mode 100644
index 0000000..0db3796
Binary files /dev/null and b/pictures/spring-session.png differ
diff --git a/spring-cloud/spring-cloud-eureka-cluster/README.md b/spring-cloud/spring-cloud-eureka-cluster/README.md
index db849a0..14cc498 100644
--- a/spring-cloud/spring-cloud-eureka-cluster/README.md
+++ b/spring-cloud/spring-cloud-eureka-cluster/README.md
@@ -1,3 +1,194 @@
-2019-01-11 11:16:14.320 INFO 13496 --- [nio-8010-exec-4] c.n.e.registry.AbstractInstanceRegistry : Registered instance SERVER/DESKTOP-8JGSFLJ:server:8010 with status UP (replication=true)
-2019-01-11 11:16:15.084 INFO 13496 --- [ Thread-41] c.n.e.registry.AbstractInstanceRegistry : Registered instance SERVER/DESKTOP-8JGSFLJ:server:8020 with status UP (replication=true)
-2019-01-11 11:16:15.085 INFO 13496 --- [ Thread-41] c.n.e.registry.AbstractInstanceRegistry : Registered instance SERVER/DESKTOP-8JGSFLJ:server:8030 with status UP (replication=true)
\ No newline at end of file
+# eureka 高可用注册中心的搭建
+
+## 一、项目结构
+
+eureka-server为服务注册中心,负责服务的管理;
+
+eureka-client 为eureka客户端;
+
+
+
+
+
+## 二、三步搭建eureka 高可用注册中心
+
+这里我们以单机伪集群的方式搭建,让三个单机注册中心互相注册,实现注册中心的高可用。配置示意图如下:
+
+
+
+#### 2.1 引入eureka服务端依赖
+
+```xml
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-server
+
+```
+
+#### 2.2 创建三份配置文件,分别代表不同注册中心的配置
+
+
+
+application-01.yml:
+
+```yaml
+spring:
+ application:
+ name: server
+server:
+ port: 8010
+eureka:
+ server:
+ # 关闭自我保护机制 开发的时候可以开启 保证不可用的服务能够及时剔除
+ enable-self-preservation: false
+ instance:
+ hostname: 127.0.0.1
+ client:
+ serviceUrl:
+ defaultZone: http://localhost:8020/eureka/,http://192.168.200.228:8030/eureka/
+```
+
+application-02.yml
+
+```yaml
+spring:
+ application:
+ name: server
+server:
+ port: 8020
+eureka:
+ server:
+ # 关闭自我保护机制 开发的时候可以开启 保证不可用的服务能够及时剔除
+ enable-self-preservation: false
+ instance:
+ hostname: localhost
+ client:
+ serviceUrl:
+ defaultZone: http://127.0.0.1:8010/eureka/,http://192.168.200.228:8030/eureka/
+```
+
+application-03.yml
+
+```yaml
+spring:
+ application:
+ name: server
+server:
+ port: 8030
+eureka:
+ server:
+ # 关闭自我保护机制 开发的时候可以开启 保证不可用的服务能够及时从列表中剔除
+ enable-self-preservation: false
+ instance:
+ hostname: 192.168.200.228
+ client:
+ serviceUrl:
+ defaultZone: http://127.0.0.1:8010/eureka/,http://localhost:8020/eureka/
+```
+
+需要注意的是Eureka互相注册要求各个Eureka实例的eureka.instance.hostname不同,如果相同,则会被Eureka标记为unavailable-replicas(不可用副本)。
+
+#### 2.3 启动类上增加注解@EnableEurekaServer激活eureka服务端自动配置
+
+```java
+@SpringBootApplication
+@EnableEurekaServer
+public class EurekaServerApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EurekaServerApplication.class, args);
+ }
+
+}
+```
+
+
+
+## 三、三步搭建eureka 客户端
+
+#### 3.1 引入eureka客户端依赖
+
+```xml
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+```
+
+#### 3.2 eureka 客户端配置,指定注册中心地址
+
+```yaml
+server:
+ port: 8040
+# 指定服务命名
+spring:
+ application:
+ name: eureka-client
+# 指定注册中心地址
+eureka:
+ client:
+ serviceUrl:
+ defaultZone: http://127.0.0.1:8010/eureka/,http://localhost:8020/eureka/,http://192.168.200.228:8030/eureka/
+```
+
+#### 3.3 启动类上增加注解@EnableDiscoveryClient激活eureka客户端自动配置
+
+```java
+@SpringBootApplication
+@EnableDiscoveryClient
+public class EurekaClientApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EurekaClientApplication.class, args);
+ }
+
+}
+```
+
+## 4.启动项目
+
+### 4.1 这里我们可以采用命令行方式指定配置,分别启动三个注册中心
+
+
+
+### 4.2 高可用集群搭建成功的判定
+
+这里需要主要的是仅仅status中出现其他注册中心时,并不一定是搭建成功的,**一定是当注册中心的DS Replicas 和 available replicas中显示其余的注册中心时候**,才代表搭建成功。
+
+#### **4.2.1 点击下面注册中心的可用实例列表中的地址,访问链接分以下几个情况:**
+
+1. hostname和prefer-ip-address都没有配置,则访问 主机名:服务名:端口号,
+
+```
+ 如:http://desktop-8jgsflj:8761/info
+```
+
+2. 配置了hostname而没有配置prefer-ip-address,则访问 hostname:服务名:端口号,
+
+ 如:http://server:8761/info
+
+3. 如果配置了prefer-ip-address,则访问 ipAddress:服务名:端口号,
+
+ 如:http://192.168.200.228:8761/info
+
+8010 注册中心:
+
+
+
+8020 注册中心:
+
+
+
+8030 注册中心:
+
+
+
+### 4.3 prefer-ip-address 参数说明
+
+在有的配置示例中,配置了prefer-ip-address为true。
+
+```properties
+eureka.instance.prefer-ip-address=true
+```
+
+在多机器独立部署的情况下是没有问题的,配置prefer-ip-address为ture,代表发现服务时候优先按照ip去搜寻,对于多集群而言,可以保证尽快准确搜索到服务。而对于单机部署来说,ip地址都是相同的,这会导致其余注册中心出现在unavailable-replicas(不可用副本)中。所以单机部署时候不建议开启这个参数(默认值为false),多机部署时候可以开启。
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-eureka/README.md b/spring-cloud/spring-cloud-eureka/README.md
index e69de29..f5b9983 100644
--- a/spring-cloud/spring-cloud-eureka/README.md
+++ b/spring-cloud/spring-cloud-eureka/README.md
@@ -0,0 +1,98 @@
+# eureka 服务的注册与发现
+
+## 一、项目结构
+
+eureka-server为服务注册中心,负责服务的管理;
+
+eureka-client 为eureka客户端;
+
+
+
+## 二、三步搭建eureka 服务注册中心
+
+#### 2.1 引入eureka服务端依赖
+
+```xml
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-server
+
+```
+
+#### 2.2 eureka 服务端配置
+
+```yaml
+server:
+ port: 8010
+eureka:
+ instance:
+ hostname: localhost
+ client:
+ # 设置为false,代表不向注册中心注册自己
+ register-with-eureka: false
+ # 注册中心主要用于维护服务,并不需要检索服务,所以设置为false
+ fetch-registry: false
+ serviceUrl:
+ defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
+```
+
+#### 2.3 启动类上增加注解@EnableEurekaServer激活eureka服务端自动配置
+
+```java
+@SpringBootApplication
+@EnableEurekaServer
+public class EurekaServerApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EurekaServerApplication.class, args);
+ }
+
+}
+```
+
+## 三、三步搭建eureka 客户端
+
+#### 3.1 引入eureka客户端依赖
+
+```xml
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+```
+
+#### 3.2 eureka 客户端配置
+
+```yaml
+server:
+ port: 8020
+# 指定服务命名
+spring:
+ application:
+ name: eureka-client
+# 指定注册中心地址
+eureka:
+ client:
+ serviceUrl:
+ defaultZone: http://localhost:8010/eureka/
+```
+
+#### 3.3 启动类上增加注解@EnableDiscoveryClient激活eureka客户端自动配置
+
+```java
+@SpringBootApplication
+@EnableDiscoveryClient
+public class EurekaClientApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EurekaClientApplication.class, args);
+ }
+
+}
+```
+
+## 4.启动项目
+
+#### 4.1 进入注册中心控制台,查看服务注册情况
+
+
\ No newline at end of file