Prerequisites
Before you begin, ensure you have the following installed on your development machine:Java JDK 21
Required for running and building the application
Apache Maven
Build automation and dependency management
PostgreSQL
Primary database for the application
Git
Version control system
Clone the Repository
Start by cloning the project repository:Database Configuration
Create PostgreSQL Database
Create a new PostgreSQL database namedbook:
Configure Application Properties
The application uses environment variables for database configuration. Set the following environment variables:The application uses
spring.jpa.hibernate.ddl-auto=create-drop in development mode, which will recreate the database schema on each startup.JWT Configuration
Configure JWT security by setting these environment variables:Dependencies Overview
The project uses the following key dependencies (defined inpom.xml):
Core Dependencies
| Dependency | Version | Purpose |
|---|---|---|
| Spring Boot | 3.5.3 | Application framework |
| Java | 21 | Programming language |
| PostgreSQL Driver | Latest | Database connectivity |
| Spring Data JPA | 3.5.3 | Database abstraction layer |
Additional Libraries
| Library | Version | Purpose |
|---|---|---|
| MapStruct | 1.6.3 | Object mapping |
| Lombok | 1.18.32 | Boilerplate code reduction |
| SpringDoc OpenAPI | 2.8.9 | API documentation (Swagger) |
| Spring Security | 3.5.3 | Authentication & authorization |
| Auth0 JWT | 4.4.0 | JWT token handling |
| JaCoCo | 0.8.13 | Code coverage analysis |
Build the Project
Using Maven Wrapper
The project includes a Maven wrapper for consistent builds:- Linux/macOS
- Windows
Using System Maven
If you have Maven installed globally:The build process includes:
- Compilation of Java sources
- Running all unit and integration tests
- Generation of MapStruct implementations
- Code coverage analysis with JaCoCo
- Packaging the application as a JAR file
MapStruct Configuration
The project uses MapStruct for object mapping between layers. The annotation processor is configured inpom.xml:
The order of annotation processors is important! Lombok must be processed before MapStruct to ensure proper code generation.
Running the Application
Development Mode
Run the application using Spring Boot Maven plugin:- Maven Wrapper
- System Maven
- Java JAR
Verify Installation
Once the application is running, verify it’s working:IDE Setup
IntelliJ IDEA
- Install Lombok Plugin: Go to Settings → Plugins → Search for “Lombok” → Install
- Enable Annotation Processing: Settings → Build, Execution, Deployment → Compiler → Annotation Processors → Enable annotation processing
- Import Project: File → Open → Select
pom.xml
Eclipse
- Install Lombok: Download lombok.jar and run
java -jar lombok.jar - Import Maven Project: File → Import → Maven → Existing Maven Projects
VS Code
- Install Extensions:
- Language Support for Java
- Spring Boot Extension Pack
- Lombok Annotations Support
- Open Project: File → Open Folder → Select project directory
Development Tools
Spring Boot DevTools
The project includes Spring Boot DevTools for automatic restart:Next Steps
Project Structure
Learn about the application architecture and package organization
Testing
Understand the testing strategy and how to run tests
API Endpoints
Explore the available API endpoints
Authentication
Learn about JWT authentication implementation
Troubleshooting
MapStruct implementations not generated
MapStruct implementations not generated
Run
mvn clean compile to regenerate MapStruct implementations. Ensure annotation processing is enabled in your IDE.Database connection errors
Database connection errors
Verify PostgreSQL is running and the environment variables are set correctly:
Port 8081 already in use
Port 8081 already in use
Change the port in
application.properties:Build fails with Lombok errors
Build fails with Lombok errors
Ensure Lombok is properly installed in your IDE and annotation processing is enabled.