A production-ready Java Spring Boot boilerplate for building scalable REST APIs with enterprise-grade patterns, comprehensive security, and AI-friendly architecture.
# Clone the repository
git clone [repository-url]
cd backend-java-spring-boot
# Build the project
mvn clean install
# Run the application
mvn spring-boot:run
# Access API documentation
open http://localhost:8080/swagger-ui.html- β Layered Architecture: Clean separation with Controller/Service/Repository/Model
- β RESTful API: Complete REST API with best practices
- β Spring Security: JWT authentication and role-based authorization
- β Data Persistence: Spring Data JPA with PostgreSQL
- β API Documentation: Interactive Swagger UI with Springdoc OpenAPI
- β Validation: Bean Validation with custom validators
- β Exception Handling: Global exception handling
- β Logging: Structured logging with SLF4J and Logback
- β‘ Caching: Redis (distributed) and Caffeine (local)
- π Async Processing: @Async support with custom thread pools
- π¨ Message Queuing: Kafka and RabbitMQ integration
- β° Scheduled Tasks: @Scheduled tasks
- π File Handling: File upload/download with validation
- βοΈ Email Service: Async email sending
- π WebSockets: Real-time communication patterns
- π‘ Event-Driven: Spring Events for decoupled communication
- π§ͺ Testing: Unit, integration, and e2e test patterns
- π Monitoring: Spring Boot Actuator with custom metrics
- π³ Docker: Docker and Docker Compose support
- π Migrations: Flyway for version-controlled schema changes
- π Profiles: Dev, staging, production configurations
- β Code Quality: Checkstyle, SpotBugs, PMD
| Category | Technology |
|---|---|
| Runtime | Java 21 LTS |
| Framework | Spring Boot 3.x |
| Build Tool | Maven |
| Database | PostgreSQL (default) |
| ORM | Spring Data JPA + Hibernate |
| Authentication | Spring Security + JWT |
| API Docs | Springdoc OpenAPI |
| Testing | JUnit 5, Mockito, Spring Boot Test |
| Caching | Redis, Caffeine |
| Messaging | Kafka, RabbitMQ |
| Deployment | Docker, Kubernetes |
| Monitoring | Actuator, Micrometer |
- Java 21 or higher (Download)
- Maven 3.8+ (Download)
- PostgreSQL 14+ (Download) - Optional, H2 available for dev
- Docker (Optional) - For containerized deployment
You don't need to build from source to use this boilerplate, but if you want to customize or contribute:
# Clone the repository
git clone [repository-url]
cd backend-java-spring-boot
# Build the project (skip tests for faster build)
mvn clean install -DskipTests
# Build with tests
mvn clean install
# Package as JAR
mvn clean package# Using Maven
mvn spring-boot:run
# Using Java directly
java -jar target/spring-boot-api-0.0.1-SNAPSHOT.jar
# With specific profile
mvn spring-boot:run -Dspring-boot.run.profiles=dev# Check if application is running
curl http://localhost:8080/actuator/health
# Access Swagger UI
open http://localhost:8080/swagger-ui.htmlHaving trouble with the boilerplate? We're here to help!
- Getting Started Guide - Step-by-step tutorial for first-time users
- Full Documentation - Complete project documentation
- API Documentation - API specifications and examples
- Troubleshooting Guide - Common issues and solutions
- Stack Overflow - Tag your questions with
spring-bootandjava - GitHub Discussions - Ask questions and discuss features
- GitHub Issues - Report bugs and request features
- Search existing issues - Your question might already be answered
- Check the documentation - Especially the Getting Started and Troubleshooting guides
- Provide details - Include Spring Boot version, Java version, and error messages
- Create a minimal reproducible example - Helps us help you faster
Found a bug? Please create an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Environment details (Java version, OS, etc.)
- Stack traces or error messages
See our Issue Template for more details.
backend-java-spring-boot/
βββ .ai/ # AI-specific configuration
β βββ context.yaml # Project metadata
β βββ mcp-config.json # MCP server config
β βββ agent-instructions.md
βββ .claude/ # Claude Code commands
β βββ commands/ # Custom commands
β βββ output-style.md
βββ docs/ # Project documentation
β βββ index.md # Main documentation entry
β βββ architecture/ # Architecture docs
β βββ guides/ # Setup & deployment guides
β βββ status/ # Current status tracking
β βββ templates/ # Documentation templates
β βββ session-management/ # AI session tracking
β βββ _working/ # Temporary work files
βββ standards/ # Development standards
β βββ coding.md # Code conventions
β βββ patterns.md # Architectural patterns
β βββ business-rules.md # Domain logic
β βββ documentation.md # Documentation standards
βββ rules/ # Spring Boot rules
β βββ java-spring-boot-rules.md
β βββ questions.md
βββ src/ # Source code (to be created)
βββ main/
β βββ java/
β βββ resources/
βββ test/
This boilerplate follows a layered architecture pattern:
βββββββββββββββββββββββββββββββββββββββ
β Controller Layer (REST) β β HTTP Requests/Responses
βββββββββββββββββββββββββββββββββββββββ€
β Service Layer β β Business Logic
βββββββββββββββββββββββββββββββββββββββ€
β Repository Layer β β Data Access
βββββββββββββββββββββββββββββββββββββββ€
β Model Layer β β Domain Entities
βββββββββββββββββββββββββββββββββββββββ
Key Principles:
- Single Source of Truth
- SOLID Principles
- High Cohesion, Low Coupling
- AI-Friendly Documentation
| Module | Purpose | Example |
|---|---|---|
| config/ | Application configuration, security, caching | SecurityConfig.java, CacheConfig.java |
| controller/ | REST API endpoints | UserController.java |
| service/ | Business logic implementation | UserService.java |
| repository/ | Data access layer | UserRepository.java |
| model/entity/ | JPA domain entities | User.java, Product.java |
| model/dto/ | Data transfer objects | UserDTO.java, CreateUserRequest.java |
| security/ | Authentication & authorization | JwtTokenProvider.java, SecurityFilter.java |
| exception/ | Custom exceptions & handlers | GlobalExceptionHandler.java, UserNotFoundException.java |
| util/ | Utility classes | DateUtil.java, ValidationUtil.java |
| Document | Description |
|---|---|
| Project Overview | Complete project overview |
| Setup Guide | Environment setup instructions |
| Architecture | System architecture details |
| API Documentation | API specifications |
| Coding Standards | Code conventions |
| Patterns | Architectural patterns |
| Business Rules | Domain logic |
# Run all tests
mvn test
# Run with coverage
mvn verify
# Run specific test
mvn test -Dtest=UserServiceTest
# Run integration tests
mvn verify -P integration-testsCoverage Target: 80%+
# Build image
docker build -t spring-boot-api .
# Run container
docker run -p 8080:8080 spring-boot-api
# Using docker-compose
docker-compose up# Apply manifests
kubectl apply -f k8s/
# Check deployment
kubectl get podsConfiguration files are located in src/main/resources/:
application.yml- Main configurationapplication-dev.yml- Development profileapplication-prod.yml- Production profile
| Variable | Description | Default |
|---|---|---|
DB_HOST |
Database host | localhost |
DB_PORT |
Database port | 5432 |
DB_NAME |
Database name | myapp |
DB_USERNAME |
Database username | postgres |
DB_PASSWORD |
Database password | - |
JWT_SECRET |
JWT signing secret | - |
JWT_EXPIRATION |
Token expiration (ms) | 86400000 |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Follow coding standards in
standards/coding.md - Write tests for your changes
- Ensure tests pass (
mvn test) - Update documentation
- Commit changes (
git commit -m 'feat: add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Follow conventional commits:
<type>(<scope>): <subject>
feat: new feature
fix: bug fix
docs: documentation
style: formatting
refactor: code restructure
test: tests
chore: maintenance
- Phase: Documentation & Setup
- Completion: 20%
- Next: Core implementation
See progress.yaml for detailed status.
This boilerplate is designed for AI-assisted development:
- MCP Integration: Model Context Protocol for AI agents
- Structured Documentation: Machine-readable status tracking
- Context Files: AI behavior guidelines and project metadata
- Clear Patterns: Well-documented architectural patterns
- Documentation: See docs/index.md
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with:
Made with β€οΈ for the Java Spring Boot community
Last Updated: 2025-10-08