java-springboot

Provides best practices for building Spring Boot applications with Java.

Updated Dec 26, 2025
One-click install
npx skills add https://github.com/jwvdvuurst/CalculatorCollection --skill java-springboot-jwvdvuurst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-springboot
Source: https://github.com/jwvdvuurst/CalculatorCollection/tree/main/skills/java-springboot
Command: npx skills add https://github.com/jwvdvuurst/CalculatorCollection --skill java-springboot-jwvdvuurst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers often struggle to apply consistent architectural patterns when building Spring Boot applications, leading to tightly coupled code, poor testability, and configuration sprawl. This Skill guides you through established conventions for structuring, securing, and testing Spring Boot projects. ## Core Features & Use Cases - Project Structure Guidance: Recommends feature-based package organization, constructor injection, and proper use of Spring stereotypes like @Service and @RestController. - Configuration & Security Practices: Covers externalized configuration with application.yml, @ConfigurationProperties, Spring Profiles, BCrypt password encoding, and secrets management. - Testing & Data Layer Patterns: Explains JUnit 5, Mockito, test slices like @WebMvcTest and @DataJpaTest, Testcontainers, and Spring Data JPA repository patterns. - Use Case: When building a new REST API with Spring Boot, ask for guidance and receive recommendations on DTO validation, global exception handling with @ControllerAdvice, and transactional service methods. ## Quick Start Ask the assistant to review your Spring Boot controller and service classes against Spring Boot best practices.

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?

Organize code by feature or domain (e.g., com.example.app.order) rather than by technical layer. Use Spring Boot starters for dependencies and keep business logic inside @Service classes with constructor-based injection.

How to handle exceptions in Spring Boot REST APIs?

Implement a global exception handler using @ControllerAdvice with @ExceptionHandler methods to return consistent error responses. Validate request payloads on DTOs with Bean Validation annotations like @Valid and @NotNull.

Should I use field injection or constructor injection in Spring?

Constructor injection is the recommended approach. Declare dependencies as private final fields and inject them through the constructor, which makes components easier to test and dependencies explicit.

Does Spring Boot support environment-specific configuration?

Yes, Spring Profiles let you define environment-specific files like application-dev.yml and application-prod.yml. Use @ConfigurationProperties for type-safe binding and never hardcode secrets in configuration files.

What testing approach works best for Spring Boot applications?

Use JUnit 5 with Mockito for unit tests, @SpringBootTest for full integration tests, and test slices like @WebMvcTest or @DataJpaTest for isolated layers. Testcontainers provides real databases for reliable integration testing.