Spring boot web api

From joaquimscosta/arkhe-claude-plugins · View interactive version

Spring boot web api is an AI agent skill from the GitHub repository joaquimscosta/arkhe-claude-plugins. Spring Boot 4 REST API implementation patterns. Use when creating REST controllers, REST endpoints, request validation, exception handlers with ProblemDetail (RFC 9457), API versioning, content negotiation, WebFlux reactive endpoints, HTTP clients with @HttpExchange, JSON serialization with Jackson

How to use this skill

Skill file

Spring Boot Web API Layer

REST API implementation patterns for Spring Boot 4 with Spring MVC and WebFlux.

Technology Selection

| Choose | When |

|--------|------|

| Spring MVC | JPA/JDBC backend, simpler debugging, team knows imperative style |

| Spring WebFlux | High concurrency (10k+ connections), streaming, reactive DB (R2DBC) |

With Virtual Threads (Java 21+), MVC handles high concurrency without WebFlux complexity.

Core Workflow

  1. Create controller → 2. Define endpoints → 3. Add validation → 4. Handle exceptions → 5. Configure versioning

See WORKFLOW.md for detailed step-by-step instructions with code examples.

Quick Patterns

See EXAMPLES.md for complete working examples including:

Spring Boot 4 Specifics

@HttpExchange Declarative Client (Spring 7)

New declarative HTTP client interface (alternative to RestTemplate/WebClient):

@HttpExchange(url = "/users", accept = "application/json")
public interface UserClient {

    @GetExchange("/{id}")
    User getUser(@PathVariable Long id);

    @PostExchange
    User createUser(@RequestBody CreateUserRequest request);

    @DeleteExchange("/{id}")
    void deleteUser(@PathVariable Long id);
}

// Configuration
@Configuration
class ClientConfig {
    @Bean
    UserClient userClient(RestClient.Builder builder) {
        RestClient restClient = builder.baseUrl("https://api.example.com").build();
        return HttpServiceProxyFactory
            .builderFor(RestClientAdapter.create(restClient))
            .build()
            .createClient(UserClient.class);
    }
}

Benefits: Type-safe, annotation-driven, works with both RestClient and WebClient.

Detailed References

Related Skills

| Need | Skill |

|------|-------|

| DDD concepts | domain-driven-design |

| Data layer for DTOs | spring-boot-data-ddd |

| Controller testing | spring-boot-testing |

| API security | spring-boot-security |

Anti-Pattern Checklist

| Anti-Pattern | Fix |

|--------------|-----|

| Business logic in controllers | Delegate to application services |

| Returning entities directly | Convert to DTOs |

| Generic error messages | Use typed ProblemDetail with error URIs |

| Missing validation | Add @Valid on @RequestBody |

| Blocking calls in WebFlux | Use reactive operators only |

| Catching exceptions silently | Let propagate to @RestControllerAdvice |

Critical Reminders

  1. Controllers are thin — Delegate to services, no business logic
  2. Validate at the boundary — @Valid on all request bodies
  3. Use ProblemDetail — Structured errors for all exceptions
  4. Version from day one — Easier than retrofitting
  5. @MockitoBean not @MockBean — Spring Boot 4 change
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.