Skip to content
Back to skills

Spring Boot Web Api

ASecurity

Spring Boot 4 REST API implementation patterns. Use when creating REST controllers, request validation, exception handlers with ProblemDetail (RFC 9457), API versioning, content negotiation, or WebFlux reactive endpoints. Covers @RestController patterns, Bean Validation 3.1, global error handling, and Jackson 3 configuration.

  • 21 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added February 8, 2026
developmentgojavakotlinreactspringtestingdebuggingapibackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add joaquimscosta/arkhe-claude-plugins --skill spring-boot-web-api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Spring Boot Web Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Spring Boot Web Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/joaquimscosta-spring-boot-web-api/badge)](https://www.skillsdirectory.com/skills/joaquimscosta-spring-boot-web-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: spring-boot-web-api
description: Spring Boot 4 REST API implementation patterns. Use when creating REST controllers, request validation, exception handlers with ProblemDetail (RFC 9457), API versioning, content negotiation, or WebFlux reactive endpoints. Covers @RestController patterns, Bean Validation 3.1, global error handling, and Jackson 3 configuration.
---

# 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** → `@RestController` with `@RequestMapping` base path
2. **Define endpoints** → `@GetMapping`, `@PostMapping`, etc.
3. **Add validation** → `@Valid` on request body, custom validators
4. **Handle exceptions** → `@RestControllerAdvice` with `ProblemDetail`
5. **Configure versioning** → Native API versioning (Spring Boot 4)

## Quick Patterns

See [EXAMPLES.md](EXAMPLES.md) for complete working examples including:
- **REST Controller** with CRUD operations and pagination (Java + Kotlin)
- **Request/Response DTOs** with Bean Validation 3.1
- **Global Exception Handler** using ProblemDetail (RFC 9457)
- **Native API Versioning** with header configuration
- **Jackson 3 Configuration** for custom serialization
- **Controller Testing** with @WebMvcTest

## Spring Boot 4 Specifics

- **Jackson 3** uses `tools.jackson` package (not `com.fasterxml.jackson`)
- **ProblemDetail** enabled by default: `spring.mvc.problemdetails.enabled=true`
- **API Versioning** via `version` attribute in mapping annotations
- **@MockitoBean** replaces `@MockBean` in tests
- **@HttpExchange** declarative HTTP clients (replaces RestTemplate patterns)
- **RestTestClient** new fluent API for testing REST endpoints

## @HttpExchange Declarative Client (Spring 7)

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

```java
@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

- **Examples**: See [EXAMPLES.md](EXAMPLES.md) for complete working code examples
- **Troubleshooting**: See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for common issues and Boot 4 migration
- **Controllers & Validation**: See [references/CONTROLLERS.md](references/CONTROLLERS.md) for validation groups, custom validators, content negotiation
- **Error Handling**: See [references/ERROR-HANDLING.md](references/ERROR-HANDLING.md) for ProblemDetail patterns, exception hierarchy
- **WebFlux Patterns**: See [references/WEBFLUX.md](references/WEBFLUX.md) for reactive endpoints, functional routers, WebTestClient

## 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

Files in this skill

  • EXAMPLES.md7 KB
  • SKILL.md4.3 KB
  • TROUBLESHOOTING.md6.9 KB
  • references/controllers.md12.5 KB
  • references/error-handling.md13.7 KB
  • references/webflux.md12.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.