Spring Boot Project
Language: Java October 15, 2025
Instruction file for Spring Boot framework with modern Java best practices.
---
applyTo: "**/*.java"
---
# Spring Boot Development Instructions (2025)
_Last updated: October 2025_
- Always use the fetch tool to look up the latest Spring Boot documentation: https://spring.io/projects/spring-boot
- Use Spring Boot 3+ with Java 17 or higher
- Follow Spring conventions and use auto-configuration where possible
- Implement dependency injection with constructor injection (preferred over field injection)
- Use Spring Data JPA for database operations with proper entity relationships
- Implement RESTful APIs with Spring Web MVC or Spring WebFlux for reactive applications
**Core Principles:**
- Use annotation-based configuration (@SpringBootApplication, @Service, @Repository, @Controller)
- Implement layered architecture (Controller → Service → Repository)
- Use DTOs for data transfer between layers
- Follow SOLID principles and clean code practices
- Use Lombok to reduce boilerplate code
**Database:**
- Use Spring Data JPA repositories for database access
- Define entities with proper JPA annotations (@Entity, @Table, @Column)
- Implement database migrations with Flyway or Liquibase
- Use pagination and sorting for large datasets
- Implement auditing with @CreatedDate and @LastModifiedDate
**Configuration:**
- Use application.yml or application.properties for configuration
- Implement profiles for different environments (dev, test, prod)
- Use @ConfigurationProperties for type-safe configuration
- Externalize sensitive data with environment variables or Spring Cloud Config
- Use @Value for simple property injection
**Security:**
- Implement Spring Security for authentication and authorization
- Use JWT tokens for stateless authentication in microservices
- Implement method-level security with @PreAuthorize
- Use password encoding with BCryptPasswordEncoder
- Implement CORS configuration for API access
**Testing:**
- Use JUnit 5 and Mockito for unit testing
- Implement integration tests with @SpringBootTest
- Use @WebMvcTest for controller testing
- Use @DataJpaTest for repository testing
- Implement test containers for database integration tests
**Performance:**
- Use caching with @Cacheable and Spring Cache abstraction
- Implement async processing with @Async
- Use connection pooling (HikariCP is default)
- Implement pagination for large datasets
- Use lazy loading for entity relationships
**Microservices:**
- Use Spring Cloud for microservices architecture
- Implement service discovery with Eureka
- Use API Gateway with Spring Cloud Gateway
- Implement circuit breakers with Resilience4j
- Use distributed tracing with Sleuth and Zipkin
**Summary:**
> For all Spring Boot work, always use the fetch tool to look up the latest documentation from https://spring.io/projects/spring-boot. Write clean, maintainable Java code following Spring best practices. Spring Boot Java Backend Framework Enterprise Microservices