Smithery Logo
MCPsSkillsDocsPricing
Login
Smithery Logo

Give agents more agency

Resources

DocumentationPrivacy PolicySystem Status

Company

PricingAboutBlog

Connect

© 2026 Smithery. All rights reserved.

    phuccodenub

    spring-boot-patterns

    phuccodenub/spring-boot-patterns
    Coding

    About

    SKILL.md

    Install

    • Claude Code
      Claude Code
    • Codex
      Codex
    • OpenClaw
      OpenClaw
    • Cursor
      Cursor
    • Amp
      Amp
    • GitHub Copilot
      GitHub Copilot
    • Gemini CLI
      Gemini CLI
    • Kilo Code
      Kilo Code
    • Junie
      Junie
    • Replit
      Replit
    • Windsurf
      Windsurf
    • Cline
      Cline
    • Continue
      Continue
    • OpenCode
      OpenCode
    • OpenHands
      OpenHands
    • Roo Code
      Roo Code
    • Augment
      Augment
    • Goose
      Goose
    • Trae
      Trae
    • Zencoder
      Zencoder
    • Antigravity
      Antigravity
    • Download skill
    ├─
    ├─
    └─

    About

    Spring Boot 3 patterns for controllers, services, configuration, and validation

    SKILL.md

    Spring Boot Patterns

    Spring Boot 3.x best practices for enterprise Java APIs. Architecture and clarity over framework tricks.

    Selective Reading Rule

    Read only files relevant to the request. Use the content map to focus.

    Content Map

    File Description When to Read
    layered-arch.md Controller -> Service -> Repository Architecture design
    rest-api.md REST endpoints, DTOs, validation API development
    configuration.md @ConfigurationProperties, profiles Config and envs
    exceptions.md @ControllerAdvice, ProblemDetail Error handling
    observability.md Actuator, logging, metrics Production readiness

    Core Patterns

    1. Layered Architecture

    Controller -> Service -> Repository
    

    Keep controllers thin, services own business rules, repositories focus on data access.

    2. REST Controller + DTOs

    @RestController
    @RequestMapping("/api/v1/users")
    @RequiredArgsConstructor
    @Validated
    public class UserController {
    
        private final UserService userService;
    
        @GetMapping("/{id}")
        public UserResponse findById(@PathVariable String id) {
            return userService.findById(id)
                .map(UserResponse::from)
                .orElseThrow(() -> new ResourceNotFoundException("User", id));
        }
    
        @PostMapping
        @ResponseStatus(HttpStatus.CREATED)
        public UserResponse create(@Valid @RequestBody CreateUserRequest request) {
            return UserResponse.from(userService.create(request.toCommand()));
        }
    }
    
    public record CreateUserRequest(
        @NotBlank @Email String email,
        @NotBlank @Size(min = 2, max = 100) String name
    ) {
        public CreateUserCommand toCommand() {
            return new CreateUserCommand(email, name);
        }
    }
    

    3. Configuration Properties

    @ConfigurationProperties(prefix = "app")
    @Validated
    public record AppProperties(
        @NotBlank String name,
        @NotNull SecurityProperties security
    ) {
        public record SecurityProperties(
            @NotBlank String jwtSecret,
            @Positive int jwtExpirationMinutes
        ) {}
    }
    

    4. Error Handling

    @RestControllerAdvice
    public class GlobalExceptionHandler {
    
        @ExceptionHandler(ResourceNotFoundException.class)
        public ProblemDetail handleNotFound(ResourceNotFoundException ex) {
            return ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
        }
    }
    

    Decision Checklist

    • Layered architecture respected?
    • DTOs separated from entities?
    • Validation at API boundary?
    • Exceptions centralized?
    • Config externalized?

    Anti-Patterns

    Anti-Pattern Why Bad Better Approach
    Business logic in controller Hard to test Move to service
    Field injection Hidden deps Constructor injection
    Entity in response Leaks internals DTO pattern
    open-in-view true Hidden queries Fetch explicitly

    Related Skills

    Need Skill
    Data access @[skills/spring-data-jpa]
    Security @[skills/spring-security]
    Testing @[skills/spring-testing]
    Recommended Servers
    vastlint - IAB XML VAST validator and linter
    vastlint - IAB XML VAST validator and linter
    VAT Validator MCP
    VAT Validator MCP
    OpenZeppelin
    OpenZeppelin
    Repository
    phuccodenub/kit_analyze
    Files