diff --git a/README.md b/README.md index 43088be5aefbcbe28a3761d5c8ea1b962ad3301f..d0a8eb96707c3cf6c27454a7a5850686ff9c66b6 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,6 @@ SpringBoot应用集合 - [Springboot配置全局异常](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-Exception) - [SpringBoot集成阿里巴巴Druid监控](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-Druid) - [SpringBoot整合Httpclient](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-Httpclient) -- [SpringBoot-Admin实现监控](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/SpringBoot-Admin-Parent) \ No newline at end of file +- [SpringBoot-Admin实现监控](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/SpringBoot-Admin-Parent) +- [SpringBoot不同环境打包配置](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-Springsession) +- [SpringBoot利用springsession实现session共享](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-Springsession) \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/README.MD b/Springboot-DifferentEnv-Pack/README.MD new file mode 100644 index 0000000000000000000000000000000000000000..793a33719c4a0c88bc2b0910942036cc6232bb9f --- /dev/null +++ b/Springboot-DifferentEnv-Pack/README.MD @@ -0,0 +1,4 @@ +# 该案例用于演示不用环境打包 +clean package -Pdev 开发环境 +clean package -Pstg 测试环境 +clean package -Pprd 生产环境 \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/pom.xml b/Springboot-DifferentEnv-Pack/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..e9768c2bc01589c48c9dbcad9b6081d9786511e9 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/pom.xml @@ -0,0 +1,141 @@ + + 4.0.0 + com.button + Springboot-DifferentEnv-Pack + 0.0.1-SNAPSHOT + jar + + + UTF-8 + UTF-8 + 1.8 + + + org.springframework.boot + spring-boot-starter-parent + 2.0.1.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + true + true + + + + + + dev + + dev + + + + true + + + + + stg + + stg + + + + + prd + + prd + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + true + + com.button.pack.SpringBootPackApplication + + + + + repackage + + + + + + maven-resources-plugin + + UTF-8 + true + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.springframework.boot + spring-boot-maven-plugin + + -Dfile.encoding=UTF-8 + true + + + + + + + src/main/resources + + + + env/* + + + mybatis/mapper/* + *.txt + + + + + src/main/resources + + true + + application.yml + + + + src/main/resources/env/${profiles.active} + true + + + + \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/java/com/button/pack/SpringBootPackApplication.java b/Springboot-DifferentEnv-Pack/src/main/java/com/button/pack/SpringBootPackApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..0e49040518ff408ec5ae04adb48c356d548ac182 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/java/com/button/pack/SpringBootPackApplication.java @@ -0,0 +1,11 @@ +package com.button.pack; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootPackApplication { + public static void main(String[] args) { + SpringApplication.run(SpringBootPackApplication.class, args); + } +} diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/123.txt b/Springboot-DifferentEnv-Pack/src/main/resources/123.txt new file mode 100644 index 0000000000000000000000000000000000000000..63a9c0c9293edbbf35e642108bcfe0e73d2123d2 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/123.txt @@ -0,0 +1 @@ +这只是为了演示,没有用处 \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/application.yml b/Springboot-DifferentEnv-Pack/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..1e3e67fa5e3d0f35c5fb37f278bf64c3f3c1ad77 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: @profiles.active@ \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/env/dev/application-dev.yml b/Springboot-DifferentEnv-Pack/src/main/resources/env/dev/application-dev.yml new file mode 100644 index 0000000000000000000000000000000000000000..94b6a1095f450ad05e921355cbfbd394b1e80298 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/env/dev/application-dev.yml @@ -0,0 +1,9 @@ +server: + servlet: + context-path: /pack + port: 8080 + uri-encoding: utf-8 + +logging: + file: logback.xml + \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/env/dev/logback.xml b/Springboot-DifferentEnv-Pack/src/main/resources/env/dev/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..981388611b7183d8bbb237ce97392db680e366c0 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/env/dev/logback.xml @@ -0,0 +1,14 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + + + + \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/env/prd/application-prd.yml b/Springboot-DifferentEnv-Pack/src/main/resources/env/prd/application-prd.yml new file mode 100644 index 0000000000000000000000000000000000000000..b20c86b57b7b16a931b37c563f49ed35de54dd32 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/env/prd/application-prd.yml @@ -0,0 +1,8 @@ +server: + servlet: + context-path: /pack + port: 8082 + uri-encoding: utf-8 + +logging: + file: logback.xml diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/env/prd/logback.xml b/Springboot-DifferentEnv-Pack/src/main/resources/env/prd/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..a38ed888af28a19303aac719f426f6cff1675b74 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/env/prd/logback.xml @@ -0,0 +1,30 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + ${LOG_HOME}/springboot_pack.log + + + ${LOG_HOME}/springboot_pack.log.%d{yyyy-MM-dd}.%i.log + + + 100MB + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + + + + + \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/env/stg/application-stg.yml b/Springboot-DifferentEnv-Pack/src/main/resources/env/stg/application-stg.yml new file mode 100644 index 0000000000000000000000000000000000000000..6adeefcdd3460237e58b9921b4b680053b73ffb0 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/env/stg/application-stg.yml @@ -0,0 +1,9 @@ +server: + servlet: + context-path: /pack + port: 8081 + uri-encoding: utf-8 + +logging: + file: logback.xml + \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/env/stg/logback.xml b/Springboot-DifferentEnv-Pack/src/main/resources/env/stg/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..981388611b7183d8bbb237ce97392db680e366c0 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/env/stg/logback.xml @@ -0,0 +1,14 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + + + + \ No newline at end of file diff --git a/Springboot-DifferentEnv-Pack/src/main/resources/mybatis/mapper/test.xml b/Springboot-DifferentEnv-Pack/src/main/resources/mybatis/mapper/test.xml new file mode 100644 index 0000000000000000000000000000000000000000..b994f53627533cda276d296f0ad2b205d30f10a7 --- /dev/null +++ b/Springboot-DifferentEnv-Pack/src/main/resources/mybatis/mapper/test.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Springboot-Springsession/README.MD b/Springboot-Springsession/README.MD new file mode 100644 index 0000000000000000000000000000000000000000..75d0ae7429865700c01cb8717f916cfb4faf418f --- /dev/null +++ b/Springboot-Springsession/README.MD @@ -0,0 +1,3 @@ +# 该案例用于演示Springboot整合Springsession实现session共享 +http://localhost:8080/session/sessions +关于启动异常:https://blog.csdn.net/oarsman/article/details/52801877 \ No newline at end of file diff --git a/Springboot-Springsession/pom.xml b/Springboot-Springsession/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3bc1d809547982569e55de4e9b60ed33d8379310 --- /dev/null +++ b/Springboot-Springsession/pom.xml @@ -0,0 +1,68 @@ + + 4.0.0 + com.button + Springboot-Springsession + 0.0.1-SNAPSHOT + jar + + + UTF-8 + UTF-8 + 1.8 + + + org.springframework.boot + spring-boot-starter-parent + 2.0.1.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.session + spring-session-data-redis + + + org.quartz-scheduler + quartz-jobs + + + org.quartz-scheduler + quartz + + + org.springframework + spring-context + + + + + org.springframework.boot + spring-boot-devtools + true + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + + -Dfile.encoding=UTF-8 + true + + + + + \ No newline at end of file diff --git a/Springboot-Springsession/src/main/java/com/button/session/SpringBootSessionApplication.java b/Springboot-Springsession/src/main/java/com/button/session/SpringBootSessionApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..807074f8e8fc3b9462774cf3cc5ee70218556892 --- /dev/null +++ b/Springboot-Springsession/src/main/java/com/button/session/SpringBootSessionApplication.java @@ -0,0 +1,11 @@ +package com.button.session; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootSessionApplication { + public static void main(String[] args) { + SpringApplication.run(SpringBootSessionApplication.class, args); + } +} diff --git a/Springboot-Springsession/src/main/java/com/button/session/controller/SessionController.java b/Springboot-Springsession/src/main/java/com/button/session/controller/SessionController.java new file mode 100644 index 0000000000000000000000000000000000000000..c86115b425f170fcbbd3b01ef6ae33803a9277a4 --- /dev/null +++ b/Springboot-Springsession/src/main/java/com/button/session/controller/SessionController.java @@ -0,0 +1,20 @@ +package com.button.session.controller; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class SessionController { + @GetMapping(value = "/sessions") + public Object sessions(HttpServletRequest request) { + Map map = new HashMap<>(); + map.put("sessionId", request.getSession().getId()); + map.put("message", request.getSession().getAttribute("map")); + return map; + } +} diff --git a/Springboot-Springsession/src/main/java/com/button/session/controller/config/RedisSessionConfig.java b/Springboot-Springsession/src/main/java/com/button/session/controller/config/RedisSessionConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..6e0d198107b8b4c8af40c423b0e8195f8a306276 --- /dev/null +++ b/Springboot-Springsession/src/main/java/com/button/session/controller/config/RedisSessionConfig.java @@ -0,0 +1,10 @@ +package com.button.session.controller.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; + +@Configuration +@EnableRedisHttpSession +public class RedisSessionConfig { + +} diff --git a/Springboot-Springsession/src/main/resources/application.yml b/Springboot-Springsession/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..225ea697dc70ded7c808d4700597feae6c26de01 --- /dev/null +++ b/Springboot-Springsession/src/main/resources/application.yml @@ -0,0 +1,14 @@ +server: + servlet: + context-path: /session + port: 8080 + uri-encoding: utf-8 + +logging: + file: logback.xml + +spring: + redis: + host: www.radiobutton.shop + port: 6379 + password: 940126zhzh \ No newline at end of file diff --git a/Springboot-Springsession/src/main/resources/logback.xml b/Springboot-Springsession/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..d0e39f897ca3d74e83ab116e3d3591b462e509e3 --- /dev/null +++ b/Springboot-Springsession/src/main/resources/logback.xml @@ -0,0 +1,30 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + ${LOG_HOME}/springboot_session.log + + + ${LOG_HOME}/springboot_session.log.%d{yyyy-MM-dd}.%i.log + + + 100MB + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + + + + + \ No newline at end of file