- Home
- Skills
- Gentleman Programming
- Gentleman Skills
- Spring Boot 3
spring-boot-3_skill
198
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill gentleman-programming/gentleman-skills --skill spring-boot-3- SKILL.md3.6 KB
Overview
This skill captures recommended Spring Boot 3 patterns for configuration, dependency injection, transaction management, and web APIs. It codifies practical conventions to make services testable, validated, and easy to maintain. Use it as a quick guide when building or refactoring Spring Boot 3.3+ applications.
How this skill works
The skill inspects common design areas and prescribes focused patterns: prefer constructor injection, centralize configuration with @ConfigurationProperties plus validation, and place transaction boundaries on service-layer methods. It also shows lightweight controller patterns using records for DTOs and recommends avoiding field injection and scattered @Value usage. Follow the patterns to improve testability, validation, and separation of concerns.
When to use it
- When creating or refactoring a Spring Boot 3.3+ service or API
- When wiring beans to ensure clear dependencies and testability
- When externalizing configuration that needs validation and type safety
- When defining transactional behavior for business operations
- When designing REST controllers and request/response DTOs
Best practices
- Always use constructor injection to make dependencies explicit and mockable
- Define configuration with @ConfigurationProperties and @Validated for typed, testable settings
- Annotate business services (not controllers) with @Transactional to bound transactions
- Represent simple DTOs with Java records for concise, immutable data carriers
- Centralize configuration scanning (e.g., @ConfigurationPropertiesScan) rather than sprinkling @Value
Example use cases
- Create a PaymentProperties record with @ConfigurationProperties(prefix="payment") and validation annotations to hold provider and apiKey
- Implement OrderService with constructor injection and @Transactional for placeOrder business logic
- Build REST endpoints where controllers delegate to services and map request records to commands
- Refactor legacy code that uses field injection and multiple @Value-annotated fields into constructor-injected services and configuration properties
- Add validation for configuration early to fail fast on bad deployments
FAQ
Constructor injection makes dependencies explicit, supports immutability, and is easier to unit test without container wiring.
When should I use @Value instead of @ConfigurationProperties?
Use @Value only for one-off simple values; prefer @ConfigurationProperties for grouped, typed, and validated configuration.