- 必须使用 @RestController 注解控制器类。
- 必须使用 @RequestMapping 指定类级别的 API 路由,例如 ("/api/user")。
- 使用 @GetMapping 获取,@PostMapping 创建,@PutMapping 更新,@DeleteMapping 删除。保持路径基于资源(例如 '/users/{id}'),避免使用动词。
- 类方法中的所有依赖必须使用 @Autowired(无构造函数),除非另有说明。
- 方法的返回对象必须是 ApiResponse 类型的 ResponseEntity。
- 所有类方法的逻辑必须在 try..catch 块中实现。
- catch 块中捕获的错误必须由自定义的 GlobalExceptionHandler 类处理。
Springboot Jpa Restcontroller Conventions
为 RestController 类指定标准,包括 API 路由映射、HTTP 方法注解、依赖注入以及使用 ApiResponse 和 GlobalExceptionHandler 进行错误处理。
Springboot Jpa Restcontroller Conventions by liaosw97 · 35420e3
npx skillmds@latest add liaosw97/springboot-jpa-restcontroller-conventions File contents
---name: springboot-jpa-restcontroller-conventionsdescription: 为 RestController 类指定标准,包括 API 路由映射、HTTP 方法注解、依赖注入以及使用 ApiResponse 和 GlobalExceptionHandler 进行错误处理。---- 必须使用 @RestController 注解控制器类。- 必须使用 @RequestMapping 指定类级别的 API 路由,例如 ("/api/user")。- 使用 @GetMapping 获取,@PostMapping 创建,@PutMapping 更新,@DeleteMapping 删除。保持路径基于资源(例如 '/users/{id}'),避免使用动词。- 类方法中的所有依赖必须使用 @Autowired(无构造函数),除非另有说明。- 方法的返回对象必须是 ApiResponse 类型的 ResponseEntity。- 所有类方法的逻辑必须在 try..catch 块中实现。- catch 块中捕获的错误必须由自定义的 GlobalExceptionHandler 类处理。
liaosw97/awesome-rules-skills/tree/main/plugins/springboot/skills/springboot-jpa-restcontroller-conventions commit 35420e3e6c
Frequently asked questions
Run npx skillmds@latest add liaosw97/springboot-jpa-restcontroller-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
为 RestController 类指定标准,包括 API 路由映射、HTTP 方法注解、依赖注入以及使用 ApiResponse 和 GlobalExceptionHandler 进行错误处理。 It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
liaosw97 (@liaosw97) published this skill. Their other Agent Skills are listed on their SkillMD profile.