From b2c034004883a9f3c69f8da4689d897cb054491a Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Thu, 20 Feb 2025 12:19:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3/=E6=97=A5=E5=BF=97/=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 54 +++++++++---------- .../controller/front/HomeController.java | 4 ++ src/main/resources/application.yml | 6 ++- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 70d5d1e..5c699bb 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@ [![index]( https://youdoc.github.io/img/tencent.jpg )]( https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console )

- Java 17 - Spring Boot 3 - Vue 3
Github stars Github forks Gitee stars Gitee forks - visitors

## 项目简介 @@ -32,38 +28,38 @@ novel 是一套基于时下**最新** Java 技术栈 Spring Boot 3 + Vue 3 开 - Elasticsearch 8.2.0(可选) - RabbitMQ 3.10.2(可选) - XXL-JOB 2.3.1(可选) -- JDK 17 +- JDK 21 - Maven 3.8 -- IntelliJ IDEA 2021.3(可选) +- IntelliJ IDEA(可选) - Node 16.14 **注:Elasticsearch、RabbitMQ 和 XXL-JOB 默认关闭,可通过 application.yml 配置文件中相应的`enable`配置属性开启。** ## 后端技术选型 -| 技术 | 版本 | 说明 | 官网 | 学习 | -|---------------------|:------------:|---------------------| ------------------------------------- |:------------------------------------------------------------------------------------------------------------------------:| -| Spring Boot | 3.3.0 | 容器 + MVC 框架 | [进入](https://spring.io/projects/spring-boot) | [进入](https://docs.spring.io/spring-boot/docs/3.0.0/reference/html) | -| Spring AI | 1.0.0-SNAPSHOT | Spring 官方 AI 框架 | [进入](https://spring.io/projects/spring-ai) | [进入](https://docs.spring.io/spring-ai/reference/) | -| MyBatis | 3.5.9 | ORM 框架 | [进入](http://www.mybatis.org) | [进入](https://mybatis.org/mybatis-3/zh/index.html) | -| MyBatis-Plus | 3.5.3 | MyBatis 增强工具 | [进入](https://baomidou.com/) | [进入](https://baomidou.com/pages/24112f/) | -| JJWT | 0.11.5 | JWT 登录支持 | [进入](https://github.com/jwtk/jjwt) | - | -| Lombok | 1.18.24 | 简化对象封装工具 | [进入](https://github.com/projectlombok/lombok) | [进入](https://projectlombok.org/features/all) | -| Caffeine | 3.1.0 | 本地缓存支持 | [进入](https://github.com/ben-manes/caffeine) | [进入](https://github.com/ben-manes/caffeine/wiki/Home-zh-CN) | -| Redis | 7.0 | 分布式缓存支持 | [进入](https://redis.io) | [进入](https://redis.io/docs) | -| Redisson | 3.17.4 | 分布式锁实现 | [进入](https://github.com/redisson/redisson) | [进入](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | -| MySQL | 8.0 | 数据库服务 | [进入](https://www.mysql.com) | [进入](https://docs.oracle.com/en-us/iaas/mysql-database/doc/getting-started.html) | -| ShardingSphere-JDBC | 5.1.1 | 数据库分库分表支持 | [进入](https://shardingsphere.apache.org) | [进入](https://shardingsphere.apache.org/document/5.1.1/cn/overview) | -| Elasticsearch | 8.2.0 | 搜索引擎服务 | [进入](https://www.elastic.co) | [进入](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) | -| RabbitMQ | 3.10.2 | 开源消息中间件 | [进入](https://www.rabbitmq.com) | [进入](https://www.rabbitmq.com/tutorials/tutorial-one-java.html) | -| XXL-JOB | 2.3.1 | 分布式任务调度平台 | [进入](https://www.xuxueli.com/xxl-job) | [进入](https://www.xuxueli.com/xxl-job) | -| Sentinel | 1.8.4 | 流量控制组件 | [进入](https://github.com/alibaba/Sentinel) | [进入](https://github.com/alibaba/Sentinel/wiki/%E4%B8%BB%E9%A1%B5) | -| Springdoc-openapi | 2.0.0 | Swagger 3 接口文档自动生成 | [进入](https://github.com/springdoc/springdoc-openapi) | [进入](https://springdoc.org/) | -| Spring Boot Admin | 3.0.0-M1 | 应用管理和监控 | [进入](https://github.com/codecentric/spring-boot-admin) | [进入](https://codecentric.github.io/spring-boot-admin/3.0.0-M1) | -| Undertow | 2.2.17.Final | Java 开发的高性能 Web 服务器 | [进入](https://undertow.io) | [进入](https://undertow.io/documentation.html) | -| Docker | - | 应用容器引擎 | [进入](https://www.docker.com/) | - | -| Jenkins | - | 自动化部署工具 | [进入](https://github.com/jenkinsci/jenkins) | - | -| Sonarqube | - | 代码质量控制 | [进入](https://www.sonarqube.org/) | - | +| 技术 | 版本 | 说明 | 官网 | 学习 | +|---------------------|:------------:|-------------------------| ------------------------------------ |:------------------------------------------------------------------------------------------------------------------------:| +| Spring Boot | 3.3.0 | 容器 + MVC 框架 | [进入](https://spring.io/projects/spring-boot) | [进入](https://docs.spring.io/spring-boot/docs/3.0.0/reference/html) | +| Spring AI | 1.0.0-SNAPSHOT | Spring 官方 AI 框架 | [进入](https://spring.io/projects/spring-ai) | [进入](https://docs.spring.io/spring-ai/reference/) | +| MyBatis | 3.5.9 | ORM 框架 | [进入](http://www.mybatis.org) | [进入](https://mybatis.org/mybatis-3/zh/index.html) | +| MyBatis-Plus | 3.5.3 | MyBatis 增强工具 | [进入](https://baomidou.com/) | [进入](https://baomidou.com/pages/24112f/) | +| JJWT | 0.11.5 | JWT 登录支持 | [进入](https://github.com/jwtk/jjwt) | - | +| Lombok | 1.18.24 | 简化对象封装工具 | [进入](https://github.com/projectlombok/lombok) | [进入](https://projectlombok.org/features/all) | +| Caffeine | 3.1.0 | 本地缓存支持 | [进入](https://github.com/ben-manes/caffeine) | [进入](https://github.com/ben-manes/caffeine/wiki/Home-zh-CN) | +| Redis | 7.0 | 分布式缓存支持 | [进入](https://redis.io) | [进入](https://redis.io/docs) | +| Redisson | 3.17.4 | 分布式锁实现 | [进入](https://github.com/redisson/redisson) | [进入](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | +| MySQL | 8.0 | 数据库服务 | [进入](https://www.mysql.com) | [进入](https://docs.oracle.com/en-us/iaas/mysql-database/doc/getting-started.html) | +| ShardingSphere-JDBC | 5.5.1 | 数据库分库分表支持 | [进入](https://shardingsphere.apache.org) | [进入](https://shardingsphere.apache.org/document/5.1.1/cn/overview) | +| Elasticsearch | 8.2.0 | 搜索引擎服务 | [进入](https://www.elastic.co) | [进入](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) | +| RabbitMQ | 3.10.2 | 开源消息中间件 | [进入](https://www.rabbitmq.com) | [进入](https://www.rabbitmq.com/tutorials/tutorial-one-java.html) | +| XXL-JOB | 2.3.1 | 分布式任务调度平台 | [进入](https://www.xuxueli.com/xxl-job) | [进入](https://www.xuxueli.com/xxl-job) | +| Sentinel | 1.8.4 | 流量控制组件 | [进入](https://github.com/alibaba/Sentinel) | [进入](https://github.com/alibaba/Sentinel/wiki/%E4%B8%BB%E9%A1%B5) | +| Springdoc-openapi | 2.0.0 | Swagger 3 接口文档自动生成 | [进入](https://github.com/springdoc/springdoc-openapi) | [进入](https://springdoc.org/) | +| Spring Boot Admin | 3.0.0-M1 | 应用管理和监控 | [进入](https://github.com/codecentric/spring-boot-admin) | [进入](https://codecentric.github.io/spring-boot-admin/3.0.0-M1) | +| Tomcat | 10.1.24 | Spring Boot 默认内嵌 Web 容器 | [进入](https://tomcat.apache.org) | [进入](https://tomcat.apache.org/tomcat-10.1-doc/index.html) | +| Docker | - | 应用容器引擎 | [进入](https://www.docker.com/) | - | +| Jenkins | - | 自动化部署工具 | [进入](https://github.com/jenkinsci/jenkins) | - | +| Sonarqube | - | 代码质量控制 | [进入](https://www.sonarqube.org/) | - | **注:更多热门新技术待集成。** diff --git a/src/main/java/io/github/xxyopen/novel/controller/front/HomeController.java b/src/main/java/io/github/xxyopen/novel/controller/front/HomeController.java index bb8074b..6eabc74 100644 --- a/src/main/java/io/github/xxyopen/novel/controller/front/HomeController.java +++ b/src/main/java/io/github/xxyopen/novel/controller/front/HomeController.java @@ -8,6 +8,7 @@ import io.github.xxyopen.novel.service.HomeService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -24,6 +25,7 @@ import java.util.List; @RestController @RequestMapping(ApiRouterConsts.API_FRONT_HOME_URL_PREFIX) @RequiredArgsConstructor +@Slf4j public class HomeController { private final HomeService homeService; @@ -34,6 +36,8 @@ public class HomeController { @Operation(summary = "首页小说推荐查询接口") @GetMapping("books") public RestResp> listHomeBooks() { + // 测试虚拟线程处理请求 + log.debug("处理请求的线程:{}", Thread.currentThread()); return homeService.listHomeBooks(); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9c8d536..d137d14 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,6 +20,10 @@ spring: threads: virtual: enabled: true + # 即使所有的用户线程(包括虚拟线程)都是守护线程的情况下,JVM 也不会立即退出, + # Spring Boot 官方建议在开启虚拟线程时设置该属性 + main: + keep-alive: true flyway: # 是否开启 Flyway @@ -38,7 +42,7 @@ server: spring: ai: openai: - api-key: + api-key: sk-rrrupturhdofbiqzjutduuiceecpvfqlnvmgcyiaipbdikoi base-url: https://api.siliconflow.cn chat: options: