Prerequisites
The backend requires the following tools:- Java 17 - Required Java version
- Maven 3.6+ - Build tool and dependency management
- PostgreSQL 16 - Database (or use Docker)
- IDE - IntelliJ IDEA or Eclipse recommended
Project Structure
The backend follows a standard Spring Boot project structure:Dependencies
Key dependencies frompom.xml:
Core Framework
- Spring Boot 3.4.5 - Main framework
- Spring Web - REST API support
- Spring Data JPA - Database access
- Spring WebFlux - Reactive HTTP client
- Spring Validation - Request validation
- Spring Cache - Caching abstraction
- Spring Actuator - Health checks and monitoring
Database
- PostgreSQL - Production database driver
- H2 - In-memory database for testing
- Flyway - Database migrations
Development Tools
- Lombok 1.18.42 - Reduce boilerplate code
- MapStruct 1.6.3 - DTO mapping
- Spring DevTools - Hot reload during development
Testing
- Spring Boot Test - Testing support
- JUnit 5 - Test framework
- Mockito - Mocking framework
- AssertJ - Fluent assertions
- Testcontainers 1.21.4 - PostgreSQL containers for integration tests
Code Quality
- JaCoCo 0.8.12 - Code coverage
- SonarQube Scanner - Code quality analysis
Building the Project
Install Dependencies
Build Without Tests
target/ directory.
Build with Code Coverage
target/site/jacoco/index.html
Running Locally
Default Profile (Dev)
http://localhost:8080.
Specific Profile
Using JAR File
Configuration
Application Properties
Key configuration inapplication.properties:
Environment Variables
Set these environment variables:IDE Setup
IntelliJ IDEA (Recommended)
-
Import Project
- Open IntelliJ IDEA
- File → Open → Select
backend/pom.xml - Import as Maven project
-
Enable Annotation Processing
- Settings → Build, Execution, Deployment → Compiler → Annotation Processors
- Check “Enable annotation processing”
- Required for Lombok and MapStruct
-
Install Lombok Plugin
- Settings → Plugins
- Search for “Lombok”
- Install and restart
-
Run Configuration
- Run → Edit Configurations
- Add new Spring Boot configuration
- Main class:
com.productdistribution.backend.BackendApplication - Environment variables: Set database credentials
Eclipse
-
Import Project
- File → Import → Existing Maven Projects
- Select
backenddirectory
-
Install Lombok
- Download
lombok.jar - Run:
java -jar lombok.jar - Select Eclipse installation directory
- Download
-
Enable Annotation Processing
- Project Properties → Java Compiler → Annotation Processing
- Enable project specific settings
VS Code
-
Install Extensions
- Extension Pack for Java
- Spring Boot Extension Pack
- Lombok Annotations Support
-
Open Folder
- Open
backenddirectory - VS Code auto-detects Maven project
- Open
Database Setup
Using Docker
Using Local PostgreSQL
Health Check
Once running, verify the application:Common Issues
Port Already in Use
Change the port inapplication.properties:
Lombok Not Working
Ensure:- Annotation processing is enabled
- Lombok plugin is installed
- IDE is restarted after plugin installation