springbootpatterns
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "springbootpatterns" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-d52dc6b660dcfdd37f1a161528fd5cf1d63e93713a51e49b49442906964ea883. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/springboot-patterns-p5ue before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Skill for SpringbootPatterns, intended to help an AI Agent efficiently perform tasks related to Spring Boot patterns and practices.
Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Controllers handle HTTP concerns. Services contain business logic. Repositories handle persistence.
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- Not specified in the source documentation.
- Software, accounts and paid services
- Not specified in the source documentation.
- Limits and differences
- Not specified in the source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: Springbootpatterns
slug: springboot-patterns
version: 1.0.0
displayName: Springbootpatterns
description: >
SpringbootPatterns专用技能,帮助AI Agent高效完成相关任务。
summary: "SpringbootPatterns专用技能,帮助AI Agent高效完成相关任务。"
license: MIT
category: 开发者工具
framework:
- Claude Code
- Codex
- Hermes Agent
- OpenClaw
- QClaw
- WorkBuddy
platform: multi-platform
homepage: "https://github.com/1991513ccie-png"
repository: "https://github.com/1991513ccie-png"Spring Boot Patterns
Layered Architecture
src/main/java/com/example/app/
config/ # @Configuration beans
controller/ # @RestController (thin, delegates to service)
service/ # @Service (business logic)
repository/ # @Repository (data access via JPA)
model/
entity/ # @Entity JPA classes
dto/ # Request/response DTOs
mapper/ # MapStruct or manual mapping
exception/ # @ControllerAdvice, custom exceptions
security/ # SecurityFilterChain, JWT filters
Controllers handle HTTP concerns. Services contain business logic. Repositories handle persistence.
REST Controller
@RestController
@RequestMapping("/api/v1/orders")
@RequiredArgsConstructor
public class OrderController {
private final OrderService orderService;
@GetMapping
public Page<OrderResponse> list(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size) {
return orderService.findAll(PageRequest.of(page, size));
}
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public OrderResponse create(@Valid @RequestBody CreateOrderRequest request) {
return orderService.create(request);
}
@GetMapping("/{id}")
public OrderResponse getById(@PathVariable UUID id) {
return orderService.findById(id);
}
}
JPA Entity and Repository
@Entity
@Table(name = "orders")
@Getter @Setter @NoArgsConstructor
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "customer_id", nullable = false)
private Customer customer;
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
private List<OrderItem> items = new ArrayList<>();
@Enumerated(EnumType.STRING)
private OrderStatus status = OrderStatus.PENDING;
@CreationTimestamp
private Instant createdAt;
}
public interface OrderRepository extends JpaRepository<Order, UUID> {
@Query("SELECT o FROM Order o JOIN FETCH o.items WHERE o.customer.id = :customerId")
List<Order> findByCustomerWithItems(@Param("customerId") UUID customerId);
@EntityGraph(attributePaths = {"customer", "items"})
Optional<Order> findWithDetailsById(UUID id);
}
Service Layer
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class OrderService {
private final OrderRepository orderRepository;
private final OrderMapper orderMapper;
private final EventPublisher eventPublisher;
public OrderResponse findById(UUID id) {
Order order = orderRepository.findWithDetailsById(id)
.orElseThrow(() -> new ResourceNotFoundException("Order", id));
return orderMapper.toResponse(order);
}
@Transactional
public OrderResponse create(CreateOrderRequest request) {
Order order = orderMapper.toEntity(request);
order = orderRepository.save(order);
eventPublisher.publish(new OrderCreatedEvent(order.getId()));
return orderMapper.toResponse(order);
}
}
Global Exception Handler
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ProblemDetail handleNotFound(ResourceNotFoundException ex) {
return ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
}
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ProblemDetail handleValidation(MethodArgumentNotValidException ex) {
ProblemDetail detail = ProblemDetail.forStatus(HttpStatus.BAD_REQUEST);
Map<String, String> errors = ex.getFieldErrors().stream()
.collect(Collectors.toMap(FieldError::getField, FieldError::getDefaultMessage));
detail.setProperty("errors", errors);
return detail;
}
}
Anti-Patterns
- Injecting repositories directly into controllers (bypassing service layer)
- Using
FetchType.EAGERon entity relationships by default - Returning JPA entities directly from controllers instead of DTOs
- Missing
@Transactional(readOnly = true)on read-only service methods - Catching generic
Exceptioninstead of specific types - Hardcoding configuration values instead of using
@Valueor@ConfigurationProperties
Checklist
- [ ] Controllers are thin and delegate to services
- [ ] All JPA relationships use
FetchType.LAZYby default - [ ] DTOs used for request/response, never raw entities
- [ ]
@Transactionalapplied at service level with correct read/write scoping - [ ] Validation annotations (
@Valid,@NotNull,@Size) on request DTOs - [ ] Global exception handler returns
ProblemDetail(RFC 7807) - [ ] Entity graphs or
JOIN FETCHused to avoid N+1 queries - [ ] Integration tests use
@SpringBootTestwith test containers
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Spring Boot 分层架构、REST 控制器、JPA 实体与仓库、服务层、全局异常处理等完整代码示例
- 包含反模式和检查清单,帮助开发者避免常见错误
- 适用于 Java 开发者学习和参考 Spring Boot 最佳实践
Areas to improve
-
触发词宽泛 Reported severity: Minor
description 仅说明为 'SpringbootPatterns专用技能',未具体说明适用场景,存在一定误触风险
Recommendation: 建议细化触发词,如 'Spring Boot 架构设计'、'JPA 最佳实践'、'REST API 开发' 等
Highlights
- description 明确说明了技能用途为帮助 AI Agent 高效完成相关任务
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
文档缺少明确的 'When to Use' 章节,用户可能不清楚何时使用该技能
Recommendation: 建议添加 'When to Use' 章节,说明适用场景和使用时机
Highlights
- 文档结构清晰,包含分层架构、代码示例、反模式、检查清单等
- frontmatter 完整,包含 name、slug、version、displayName、description、summary、license、category、framework、platform、homepage、repository 等信息
- 代码示例完整,格式规范,易于理解
Highlights
- 代码示例完整,工具来源明确(Spring Boot、JPA),参数使用正确
- 覆盖了主要异常处理,如 ResourceNotFoundException、MethodArgumentNotValidException
- 提供了全局异常处理器,返回符合 RFC 7807 标准的 ProblemDetail
- 包含了避免 N+1 查询的最佳实践(Entity graphs 或 JOIN FETCH)
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Save or modify files
Confirm the output directory and whether existing files will be replaced. Back up important files and prefer a new output directory.
Mentioned in main document · lines 130
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- github.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Not specified in the source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.