From 0341ebc8351d23e8437b4391dffe911f5ea19623 Mon Sep 17 00:00:00 2001 From: whai Date: Sun, 24 Nov 2024 11:06:37 +0800 Subject: [PATCH] =?UTF-8?q?build(SpringDemo):=20=E6=9B=B4=E6=96=B0=20Maven?= =?UTF-8?q?=20=E4=BE=9D=E8=B5=96=E5=B9=B6=E7=A7=BB=E9=99=A4=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了 Spring Boot 安全、集成和 IP 相关依赖 - 移除了 SSEEmitter 类的实现 - 添加了 SwaggerConfig 类的配置 --- SpringDemo/pom.xml | 23 +++- .../springdemo/config/SwaggerConfig.java | 42 +++++++ .../springdemo/controller/SSE/SSEEmitter.java | 104 +++++++++--------- .../src/main/resources/template/empty.xlsx | Bin 0 -> 9818 bytes 4 files changed, 113 insertions(+), 56 deletions(-) create mode 100644 SpringDemo/src/main/java/cn/whaifree/springdemo/config/SwaggerConfig.java create mode 100644 SpringDemo/src/main/resources/template/empty.xlsx diff --git a/SpringDemo/pom.xml b/SpringDemo/pom.xml index 07cc19a..db4fefb 100644 --- a/SpringDemo/pom.xml +++ b/SpringDemo/pom.xml @@ -30,7 +30,11 @@ 17 - + + + org.springframework.boot + spring-boot-starter-security + org.apache.poi @@ -44,6 +48,23 @@ 5.0.0 + + org.springframework.boot + spring-boot-starter-integration + + + + + org.springframework.integration + spring-integration-ip + + + + + + + + com.github.ben-manes.caffeine diff --git a/SpringDemo/src/main/java/cn/whaifree/springdemo/config/SwaggerConfig.java b/SpringDemo/src/main/java/cn/whaifree/springdemo/config/SwaggerConfig.java new file mode 100644 index 0000000..22fa38f --- /dev/null +++ b/SpringDemo/src/main/java/cn/whaifree/springdemo/config/SwaggerConfig.java @@ -0,0 +1,42 @@ +//package cn.whaifree.springdemo.config; +// +//import io.swagger.v3.oas.models.ExternalDocumentation; +//import io.swagger.v3.oas.models.OpenAPI; +//import io.swagger.v3.oas.models.info.Info; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +// +//import java.util.ArrayList; +// +///** +// * Created with IntelliJ IDEA. +// * +// * @author : 村雨遥 +// * @version : 1.0 +// * @project : springboot-swagger3-demo +// * @package : com.cunyu.springbootswagger3demo.config +// * @className : SwaggerConfig +// * @createTime : 2022/1/6 14:19 +// * @email : 747731461@qq.com +// * @微信 : cunyu1024 +// * @公众号 : 村雨遥 +// * @网站 : https://cunyu1943.github.io +// * @description : +// */ +// +//@Configuration +//public class SwaggerConfig { +// @Bean +// public OpenAPI openAPI() { +// return new OpenAPI() +// .info(new Info() +// .title("接口文档标题") +// .description("SpringBoot3 集成 Swagger3接口文档") +// .version("v1")) +// .externalDocs(new ExternalDocumentation() +// .description("项目API文档") +// .url("/")); +// } +//} diff --git a/SpringDemo/src/main/java/cn/whaifree/springdemo/controller/SSE/SSEEmitter.java b/SpringDemo/src/main/java/cn/whaifree/springdemo/controller/SSE/SSEEmitter.java index 2ad9641..4f38f89 100644 --- a/SpringDemo/src/main/java/cn/whaifree/springdemo/controller/SSE/SSEEmitter.java +++ b/SpringDemo/src/main/java/cn/whaifree/springdemo/controller/SSE/SSEEmitter.java @@ -1,55 +1,49 @@ -package cn.whaifree.springdemo.controller.SSE; - -import cn.hutool.core.util.StrUtil; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; - -import java.io.IOException; -import java.util.Map; - -/** - * @version 1.0 - * @Author whai文海 - * @Date 2024/10/22 21:44 - * @注释 - */ -@RestController -public class SSEEmitter { - - public static void main(String[] args) { - int a = 127; - byte c = (byte) a; - System.out.println(Integer.toBinaryString(c)); - System.out.println(c); - } - Map sseEmitterMap = new java.util.HashMap<>(); - - @GetMapping(value = "/sseStart", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public SseEmitter sse(String key) { - System.out.println(key); - if (!sseEmitterMap.containsKey(key)) { - SseEmitter sseEmitter = new SseEmitter(); - sseEmitterMap.put(key, sseEmitter); - } - - return sseEmitterMap.get(key); - } - - @PostMapping("sendSSE") - public void send(String key, String message) { - if (sseEmitterMap.containsKey(key)) { - SseEmitter sseEmitter = sseEmitterMap.get(key); - try { - System.out.println(StrUtil.format("send message to {}:{}", key, message)); - sseEmitter.send(message); - } catch (IOException e) { - e.printStackTrace(); - } - }else { - throw new IllegalArgumentException("No such key"); - } - } -} +//package cn.whaifree.springdemo.controller.SSE; +// +//import cn.hutool.core.util.StrUtil; +//import org.springframework.http.MediaType; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RestController; +//import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +// +//import java.io.IOException; +//import java.util.Map; +// +///** +// * @version 1.0 +// * @Author whai文海 +// * @Date 2024/10/22 21:44 +// * @注释 +// */ +//@RestController +//public class SSEEmitter { +// +// Map sseEmitterMap = new java.util.HashMap<>(); +// +// @GetMapping(value = "/sseStart", produces = MediaType.TEXT_EVENT_STREAM_VALUE) +// public SseEmitter sse(String key) { +// System.out.println(key); +// if (!sseEmitterMap.containsKey(key)) { +// SseEmitter sseEmitter = new SseEmitter(); +// sseEmitterMap.put(key, sseEmitter); +// } +// +// return sseEmitterMap.get(key); +// } +// +// @PostMapping("sendSSE") +// public void send(String key, String message) { +// if (sseEmitterMap.containsKey(key)) { +// SseEmitter sseEmitter = sseEmitterMap.get(key); +// try { +// System.out.println(StrUtil.format("send message to {}:{}", key, message)); +// sseEmitter.send(message); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// }else { +// throw new IllegalArgumentException("No such key"); +// } +// } +//} diff --git a/SpringDemo/src/main/resources/template/empty.xlsx b/SpringDemo/src/main/resources/template/empty.xlsx new file mode 100644 index 0000000000000000000000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