SpringBoot Common Components
Paste the following prompt into your AI chat to install this skill:
Please follow https://skillhub.cn/install/skillhub.md to install @user_faca7523/springboot-common.
About this skill
Problem
In many SpringBoot projects, response shapes, exception handling, request tracing, and user context are scattered across controllers and services. This leads to inconsistent API fields, swallowed exceptions, and logs missing requestId. This skill turns those concerns into reusable components, suitable for adding an engineering baseline to an existing project generated by springboot-init.
How It Works
It generates code around Result, GlobalExceptionHandler, UserContext, ShowLogAspect, and ResultAdvice:
- Unified response: adds Result, ResultCode, and RequestUtils so APIs return a standard structure with requestId.
- Exception handling: adds BizException and GlobalExceptionHandler to normalize business errors into failure responses.
- User context: UserContextInterceptor reads x-user-id and x-request-id, then stores them in ThreadLocal for logs and business code.
- AOP logging: @ShowLog with ShowLogAspect prints arguments, return values, latency, and success or exception markers.
- Dependency management: updates pom.xml, chooses javax.servlet or jakarta.servlet based on SpringBoot version, and manages Lombok, Fastjson2, and Commons dependencies.
Boundaries
It depends on the base project structure generated by springboot-init, and artifactId plus packageName are required to locate the project and generate package paths. It is better for completing shared components than replacing project initialization, authentication, or observability. If the project already has response wrappers or interceptors, applying it may create duplicate classes, so package names, configuration classes, and response advice should be reviewed manually.
Use Cases
- After creating a SpringBoot project, standardize every API response with code, message, data, and requestId.
- When custom exceptions already exist, convert them into a consistent error payload instead of leaking stack traces.
- Record method arguments, return values, latency, userId, and requestId for key APIs to support tracing.
- Read x-user-id and x-request-id in an interceptor, then store them in ThreadLocal for logs and business code.
Best For
- Backend engineers maintaining SpringBoot APIs who need a unified response and global exception baseline.
- Server-side developers debugging integrations who need userId, requestId, and latency in API logs.
- Java backend teams migrating legacy projects to a shared exception and logging convention.
- Teams using springboot-init for new projects who need AOP logging and user context added quickly.
Related Skills
A one-shot coding agent built on Claude Code CLI that runs non-interactively, supports a specified workdir, and can be monitored in the foreground or background.
Preview and confirm file sorting by extension, with recursive cleanup, ignore rules, and transactional rollback.
An engineering assistant for static HTML/CSS/JS pages, design-token extraction, IE8-compatible review, and structured delivery.
An engineering workflow for requirement analysis, scenario modeling, risk planning, quality gates, testing, and knowledge capture, with lightweight, standard, and full modes.