System Requirements
Before installing the application, ensure your system meets the following requirements:Required Software
Java JDK 21
The application is built with Java 21 and requires this specific version.
Apache Maven
Maven 3.6+ is required for building and managing dependencies.
PostgreSQL
PostgreSQL 12+ is required for data persistence.
Git
Git is needed to clone the repository.
Hardware Requirements
- RAM: Minimum 2GB, recommended 4GB+
- Disk Space: At least 500MB for the application and dependencies
- CPU: Any modern processor (dual-core or better recommended)
Installation Steps
Install Apache Maven
Download Maven from the official website and follow the installation instructions for your operating system.Verify the installation:Expected output:
Install PostgreSQL
Install PostgreSQL from the official website or use your system’s package manager:Verify PostgreSQL is running:
Database Configuration
Create the database
Connect to PostgreSQL and create the application database:Then in the PostgreSQL console:You can verify the database was created:Exit the PostgreSQL console:
Configure database credentials
The application uses environment variables for database configuration. These are referenced in Set the required environment variables:
src/main/resources/application.properties:Understand the database auto-configuration
The application is configured with For production environments, change this to:
spring.jpa.hibernate.ddl-auto=create-drop in application.properties:create-drop: The database schema is automatically created when the application starts and dropped when it stops. This is useful for development but should be changed to
update or validate for production.Application Configuration
Configure JWT security
The application uses JWT (JSON Web Token) for authentication. Configure the JWT settings using environment variables:These variables are referenced in You can generate a secure key using:
application.properties:Configure server port (optional)
The application runs on port 8081 by default:To change the port, you can:
- Modify
application.properties - Set an environment variable:
export server.port=9090 - Use a command-line argument:
mvn spring-boot:run -Dserver.port=9090
Building and Running
Install dependencies
Download all project dependencies using Maven:This command will:
- Clean previous builds
- Download dependencies from Maven Central
- Compile the source code
- Run tests
- Package the application as a JAR file
Run the application
Start the Spring Boot application:Alternatively, run the packaged JAR file:
Make sure all environment variables are set in your current shell session before running the application.
Project Dependencies
The application uses the following key dependencies (frompom.xml):
Spring Boot 3.5.3
Core framework for building the REST API
Spring Security
Security framework with JWT authentication
Spring Data JPA
Data persistence and ORM with Hibernate
PostgreSQL Driver
JDBC driver for PostgreSQL connectivity
Auth0 JWT 4.4.0
JWT token generation and validation
MapStruct 1.6.3
Object mapping between DTOs and entities
Lombok 1.18.32
Reduces boilerplate code with annotations
SpringDoc OpenAPI 2.8.9
Generates Swagger/OpenAPI documentation
Development Tools
Hot Reload
The application includes Spring Boot DevTools for automatic restart during development:Testing
Run the test suite:target/site/jacoco/index.html.
The project is configured with an 80% code coverage requirement at the package level.
Troubleshooting
Environment variables not found
Environment variables not found
Error:
Could not resolve placeholder 'db_url' in value "${db_url}"Solution: Ensure all required environment variables are set in your current shell session:db_urldb_usernamedb_passworduser_jwtkey_jwt
Database connection failed
Database connection failed
Error:
Connection to localhost:5432 refusedSolution:- Verify PostgreSQL is running:
- Check that PostgreSQL is listening on port 5432
- Verify your credentials are correct
- Ensure the
bookdatabase exists
Port 8081 already in use
Port 8081 already in use
Error:
Port 8081 is already in useSolution: Either stop the other application using port 8081, or change the application port:Maven build fails
Maven build fails
Error: Various Maven compilation errorsSolution:
- Ensure you’re using Java 21:
- Clean the Maven cache:
- Force update dependencies:
JWT token errors
JWT token errors
Error: Token signature verification failedSolution: Ensure the
key_jwt environment variable is:- Set before starting the application
- At least 256 bits (32 characters) long
- The same value used to generate the tokens
Next Steps
Quick Start
Follow the quick start guide to make your first API calls
Architecture
Learn about the application’s layered architecture
Authentication
Understand JWT authentication and security
API Reference
Explore all available API endpoints