
xxl-job-patterns
XXL-JOB 最佳实践模式。基于 hiwepy/xxljob-spring-boot-starter 定制封装,覆盖 @XxlJobCron 注解替代原生 @XxlJob(代码即配置/cron写在代码里/启动时自动注册到admin)、XxlJobTemplate 编程式任务管理(CRUD/启停/触发/session自动续期)、执行器自动配置(Unirest SSL/端口兜底/Nacos适配)、Micrometer指标集成、v2/v3双版本兼容。 纠正 LLM 误用:用 @Scheduled 替代分布式调度、不知道 XxlJobTemplate 的编程式管理、不知道 @XxlJobCron 的 selfStarting 自动注册模式。
- Installs
- 85
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/java-skills --skill xxl-job-patterns- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads xxl-job-patterns automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
XXL-JOB 最佳实践模式
来源:https://github.com/xuxueli/xxl-job
基于 hiwepy/xxljob-spring-boot-starter(Spring Boot Starter 封装)
Capability Boundaries
✅ Strong Suits
- @XxlJobCron 注解 — 100%替代@XxlJob,代码即配置(cron/desc/author/selfStarting 全部在代码中)
- 启动自动注册 — selfStarting=true 时,执行器启动自动将任务注册到Admin(无需手动在UI创建)
- XxlJobTemplate — 编程式管理任务(添加/更新/删除/启动/停止/触发),session自动续期
- v2/v3双版本兼容 — Admin版本参数差异(v3用ids[]、v2用id),自动适配
- Micrometer指标 — 自动采集任务执行次数/成功/失败/耗时,对接Prometheus
- Unirest HTTP客户端 — 自动配置SSL(trust-all)/Cookie管理/超时
❌ Out of Scope
- 简单单机定时任务 → @Scheduled
- 替代方案:PowerJob(功能更强)、ElasticJob(无中心化)
核心模式
模式 1: @XxlJobCron — 代码即配置(推荐)
@Slf4j
@Component
@RequiredArgsConstructor
public class CompensationJobHandler {
private final AigcTaskCompensationScheduler compensationScheduler;
// ✅ 一行注解 = @XxlJob + cron + desc + author + selfStarting(自动注册到Admin)
@XxlJobCron(value = "compensateStaleTextTasks",
cron = "0/30 * * * * ?",
desc = "文本回调超时补偿",
author = "wandl",
selfStarting = true, // ← 启动时自动注册,无需在Admin UI手动创建
failRetryCount = 3,
timeout = 30) // 30秒超时
public void compensateStaleTextTasks() {
try {
compensationScheduler.compensateStaleTextTasks();
XxlJobHelper.handleSuccess("compensation completed");
} catch (Exception e) {
log.error("XXL-Job failed", e);
XxlJobHelper.handleFail("failed: " + e.getMessage());
}
}
}
模式 2: XxlJobTemplate — 编程式任务管理
@Service
public class JobManager {
@Autowired XxlJobTemplate xxlJobTemplate;
// 创建/更新任务(幂等)
public void ensureJobRegistered(Long jobGroupId, String handlerName, String cron, String desc) {
XxlJobInfo jobInfo = new XxlJobInfo();
jobInfo.setJobGroup(jobGroupId.intValue());
jobInfo.setExecutorHandler(handlerName);
jobInfo.setScheduleConf(cron);
jobInfo.setJobDesc(desc);
jobInfo.setScheduleType("CRON");
jobInfo.setGlueType("BEAN");
jobInfo.setAuthor("system");
jobInfo.setExecutorRouteStrategy("LEAST_FREQUENTLY_USED");
jobInfo.setMisfireStrategy("DO_NOTHING");
jobInfo.setExecutorBlockStrategy("COVER_EARLY");
jobInfo.setExecutorTimeout(30);
jobInfo.setExecutorFailRetryCount(3);
xxlJobTemplate.addUniqueJob(jobInfo); // 幂等:描述相同不重复创建
}
// 手动触发
public void triggerJob(Integer jobId, String param) {
xxlJobTemplate.triggerJob(jobId, param);
}
// 暂停/恢复
public void pauseJob(Integer jobId) { xxlJobTemplate.stopJob(jobId); }
public void resumeJob(Integer jobId) { xxlJobTemplate.startJob(jobId); }
}
模式 3: 配置结构
xxl:
job:
accessToken: xxx # 通信Token
admin:
version: V3_X # Admin版本(V2_X / V3_X)
addresses: http://xxx:9991/xxl-job-admin
username: admin
password: xxxxx # Admin登录密码
cookie: # Session管理
maximum-size: 1000
expire-after-write: 5s
executor:
enabled: true
appname: agent-job-executor # 执行器名称(与Admin注册一致)
title: 智能体 - 任务执行器 # 执行器显示名称
ip: 172.16.0.152 # 执行器IP(多网卡时指定)
port: 0 # 0=自动探测,-1=不启动
log-path: /logs/xxl-job/jobhandler
log-retention-days: 30
模式 4: SLF4J + RequiredArgsConstructor 依赖注入
// ✅ DDD4J 风格:Lombok + 构造器注入
@Slf4j
@Component
@RequiredArgsConstructor // final字段自动构造器注入
public class MyJobHandler {
private final OrderService orderService; // 构造器注入
private final NotificationService notifyService;
@XxlJobCron(value = "closeExpiredOrders", cron = "0 0 2 * * ?",
desc = "关闭过期订单", author = "system", selfStarting = true)
public void execute() { ... }
}
模式 5: 错误处理统一模式
@XxlJobCron(...)
public void execute() {
try {
// 业务逻辑
doWork();
XxlJobHelper.handleSuccess("处理完成"); // ← 显式标记成功
} catch (Exception e) {
log.error("XXL-Job {} failed", getJobName(), e);
XxlJobHelper.handleFail("失败: " + e.getMessage()); // ← 显式标记失败
}
}
Gotchas
- @XxlJobCron(selfStarting=true) 自动注册 — 启动时自动同步到Admin,无需手动在UI创建
- Admin版本参数差异 — v2用
id,v3用ids[],Starter自动适配 - 执行器端口设为0自动探测 — 避免端口冲突,-1不启动执行器
- 多网卡指定ip — 云环境多网卡必须指定
xxl.job.executor.ip - session自动续期 — XxlJobTemplate检测session过期自动重新登录
- XxlJobHelper.handleFail显式标记 — 不调用默认视为成功
- @RequiredArgsConstructor注入 — 用final字段+构造器注入,不用@Autowired字段注入
- @XxlJobCron 与 MetricMethodJobHandler 冲突 — XXL-JOB 自带的
MetricMethodJobHandler通过反射读取@XxlJob.value(),但@XxlJobCron不包含原生@XxlJob注解,导致NullPointerException: Cannot invoke "com.xxl.job.core.handler.annotation.XxlJob.value()" because "job" is null。解决方案:① 禁用 Micrometer 指标(xxl.job.metrics.enabled=false) ② 同时在方法上添加空的@XxlJob注解解决反射问题 ③ 升级 hiwepy starter 版本看是否已修复
Data Privacy
本技能不收集、存储或传输任何用户数据。
FAQ
What does the xxl-job-patterns skill do?
XXL-JOB 最佳实践模式。基于 hiwepy/xxljob-spring-boot-starter 定制封装,覆盖 @XxlJobCron 注解替代原生 @XxlJob(代码即配置/cron写在代码里/启动时自动注册到admin)、XxlJobTemplate 编程式任务管理(CRUD/启停/触发/session自动续期)、执行器自动配置(Unirest SSL/端口兜底/Nacos适配)、Micrometer指标集成、v2/v3双版本兼容。 纠正 LLM 误用:用 @Scheduled 替代分布式调度、不知道 XxlJobTemplate 的编程式管理、不知道 @XxlJobCron 的 selfStarting 自动注册模式。
How do I install xxl-job-patterns?
Run npx skills add https://github.com/full-stack-skills/java-skills --skill xxl-job-patterns in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/xxl-job-patterns/ (personal) or .claude/skills/xxl-job-patterns/ (project).
Which AI agents can use xxl-job-patterns?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is xxl-job-patterns safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains xxl-job-patterns?
It is published by full-stack-skills in full-stack-skills/java-skills. It has 85 recorded installs.
More from full-stack-skills/java-skills
mybatis-plus-patterns
full-stack-skills/java-skills
MyBatis-Plus 增强 ORM 技能。覆盖 LambdaQueryWrapper vs QueryWrapper选择(始终Lambda)、分页插件(PaginationInnerInterceptor)配置、乐观锁(@Version + OptimisticLockerInnerInterceptor)、逻辑删除(@TableLogic 全局/局部配置)、自动填充(@TableField fill + MetaObjectHandler)、ActiveRecord vs Mapper模式选择、防全表更新(BlockAttackInnerInterceptor)、通用PageQuery抽取。 当用户使用 MyBatis-Plus 进行数据库操作、配置分页乐观锁、选择查询方式时使用。 与 mybatis 技能互补:mybatis 侧重XML/ResultMap/SQL写法,mybatis-plus 侧重增强功能。
java-development-manual
full-stack-skills/java-skills
Java开发手册规约集合,基于阿里巴巴Java开发手册(嵩山版)。 涵盖7大维度:编程规约、异常日志、单元测试、安全规约、MySQL数据库、工程结构、设计规约。 当用户需要:(1) 编写或审查Java代码 (2) 检查命名/代码规范 (3) 处理异常和日志 (4) 编写单元测试 (5) 安全编码 (6) 数据库设计 (7) 工程架构设计时使用此skill。 触发词:Java规范、阿里规约、代码规范、开发手册、编程规约、异常处理、单元测试、安全、MySQL、工程结构、设计模式。
java-code-comments
full-stack-skills/java-skills
Provides comprehensive guidance for adding Java code comments following industry standards and best practices. This skill helps add class-level comments, method-level comments, and field-level comments to Java code. Use when the user wants to add comments to Java code, needs to document Java classes/methods/fields, wants to improve code documentation, or needs to generate JavaDoc comments. This skill covers Controller, Service, ServiceImpl, Mapper, Model, Entity, BO (Business Object), DTO, VO, and other common Java component types. The skill follows a systematic workflow: scan codebase, identify components, create todo list, and add comments in order (class comments → method comments → field comments).
mybatis-patterns
full-stack-skills/java-skills
MyBatis 核心 ORM 技能。覆盖 XML vs 注解 SQL选择、ResultMap复用(extends)、关联查询(association/collection join vs 嵌套select/N+1决策)、分页插件配置、和$的SQL注入防护、动态SQL(if/where/set/foreach/choose)最佳实践、columnPrefix解决同表多次JOIN。 当用户编写 MyBatis Mapper XML、处理关联查询、配置分页、防范SQL注入时使用。
java-conventions
full-stack-skills/java-skills
统一 Java 项目编码规范与注释规范(SLF4J+Lombok 日志、Bean Lombok 注解选择、判空 Objects/Optional、工具类优先级 Spring→Apache Commons→Hutool→Guava、复杂逻辑用设计模式/简单逻辑不拆分、Controller/Service/ServiceImpl/Mapper 注释一致性)。当需要“按 Java 规范重构/Review/补全注释/统一日志/统一工具类使用/补全 JavaDoc”时使用。
junit-mockito-patterns
full-stack-skills/java-skills
JUnit5 + Mockito 测试框架技能。覆盖 JUnit5 @ExtendWith替代@RunWith、Mockito @Mock/@InjectMocks规则、测试隔离原则(FIRST)、@SpringBootTest何时用何时不用(@WebMvcTest/@DataJpaTest切片测试)、BDDMockito given/willReturn风格、ArgumentCaptor参数捕获、verify行为验证、@ParameterizedTest参数化测试。 当用户编写 Java 单元测试/集成测试、Mock外部依赖时需要此技能。
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.