java-springboot

Provides best practices for building Spring Boot applications with layered architecture.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill java-springboot-412181-heredialara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-springboot
Source: https://github.com/412181-HerediaLara/ScaffoldingBE-FE/tree/main/BE/.agents/skills/java-springboot
Command: npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill java-springboot-412181-heredialara

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers building Spring Boot applications often struggle with inconsistent project structure, improper dependency injection, exposed JPA entities, weak validation, and missing test coverage. This Skill provides a consolidated set of Spring Boot best practices so generated or reviewed code follows established conventions from the start. ## Core Features & Use Cases - Project Structure & DI Guidance: Enforces constructor injection, immutable dependencies, feature-based packaging, and proper use of Spring stereotypes. - Layered Architecture Rules: Covers controllers with DTOs and Bean Validation, stateless transactional services, and Spring Data JPA repositories with projections. - Configuration, Security & Testing: Guides externalized configuration with profiles, Spring Security with BCrypt password encoding, and testing with JUnit 5, Mockito, test slices, and Testcontainers. - Use Case: When scaffolding a new REST API for a game backend, use this Skill to generate controllers with @Valid DTOs, a @ControllerAdvice error handler, transactional services, and @WebMvcTest/@DataJpaTest test slices that meet coverage requirements. ## Quick Start Review my Spring Boot project and refactor it to follow best practices for controllers, services, repositories, validation, and testing.

Frequently Asked Questions about java-springboot

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Spring Boot project correctly?

Organize code by feature or domain (e.g., com.example.app.order) rather than by technical layer. Use Spring Boot starters for dependencies and separate controllers, services, and repositories within each feature package.

How to validate request data in Spring Boot REST APIs?

Use Java Bean Validation annotations like @NotNull and @Size on DTO fields, then annotate controller parameters with @Valid. Handle validation failures globally with @ControllerAdvice and @ExceptionHandler for consistent error responses.

Should I use field injection or constructor injection in Spring?

Use constructor-based injection with private final fields for required dependencies. This makes dependencies explicit, simplifies unit testing with mocks, and allows immutability, unlike field injection which hides requirements.

What testing approach works best for Spring Boot applications?

Write unit tests with JUnit 5 and Mockito for services, use test slices like @WebMvcTest for controllers and @DataJpaTest for repositories, and reserve @SpringBootTest for full integration tests. Testcontainers provides real databases for reliable integration testing.

Why should I not expose JPA entities directly in REST controllers?

Exposing entities leaks internal schema details, risks lazy-loading exceptions, and can expose sensitive fields. Use DTOs to control exactly what data enters and leaves the API, and map between entities and DTOs in the service layer.