# lzh-1.8-async-spring-boot-starter **Repository Path**: coding_13/lzh-1.8-async-spring-boot-starter ## Basic Information - **Project Name**: lzh-1.8-async-spring-boot-starter - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-13 - **Last Updated**: 2025-08-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # lzh-1.8-async-spring-boot-starter 一个用于简化Spring Boot异步任务处理的starter组件。它为应用程序提供异步执行能力和线程池管理。 ## 特性 - 提供可配置的异步任务线程池。 - 支持自定义线程池参数,如核心线程数、最大线程数、队列大小等。 - 保持请求上下文在异步执行期间不变。 - 集成Spring的`@EnableAsync`注解,简化异步方法调用的配置。 ## 模块结构 - `LzhAsyncTaskConfig`: 配置类,启用异步任务支持,并定义线程池Bean。 - `LzhAsyncTaskProperties`: 属性配置类,用于从`application.properties`或`application.yml`中读取线程池相关配置。 - `LzhThreadPoolTaskExecutor`: 自定义的线程池任务执行器,扩展了Spring的`ThreadPoolTaskExecutor`。 - `RequestContextAwareCallable` & `RequestContextAwareRunnable`: 确保异步任务执行时保留请求上下文的封装类。 - `RequestContextAwarePoolExecutor`: 结合请求上下文支持的线程池执行器。 ## 安装 1. 将以下依赖添加到你的`pom.xml`中: ```xml com.lzh lzh-1.8-async-spring-boot-starter 1.0.0 ``` 2. 配置异步任务相关参数,例如在`application.yml`中: ```yaml lzh: async-task: core-pool-size: 5 max-pool-size: 10 queue-size: 100 thread-name-prefix: async-task- keep-alive-time: 60 ``` ## 使用 确保你的Spring Boot主类或配置类上标注了`@EnableAsync`。然后你可以使用`@Async`注解来标记异步执行的方法。 ```java @Service public class MyAsyncService { @Async public void asyncMethod() { // 异步执行的逻辑 } } ``` ## 贡献者指南 - Fork这个仓库。 - 创建新分支 (`git checkout -b feature/your-feature-name`) - 提交更改 (`git commit -am 'Add some feature'`) - 推送分支 (`git push origin feature/your-feature-name`) - 创建新的Pull Request ## 协议 该项目基于MIT协议发布,请查看仓库中的`LICENSE`文件以获取更多信息。 ## 联系 如果你有任何问题或建议,请在Gitee上提交Issue或者联系作者。 --- 请根据实际的项目文档和代码更新配置和使用部分的具体细节。