Prerequisites
Before you begin, ensure you have the following installed:You should see Java 21 in the output.
- Java 21 - Required for Spring Boot 3.5.10
- PostgreSQL (optional) - The API uses an in-memory H2 database by default for quick setup
- Git - To clone the repository
Clone the Repository
Clone the User Management API repository and navigate to the project directory:
Build the Project
Build the project using the Gradle wrapper. This will download all dependencies and compile the application:The build process includes:
The first build may take a few minutes as Gradle downloads all dependencies. Subsequent builds will be much faster.
- Compiling Java source code
- Running unit and integration tests
- Creating the executable JAR file
Run the Application
Start the application using Gradle:You should see output similar to:The API is now running at http://localhost:8080
Make Your First API Call
Let’s register your first user! Open a new terminal window and run:Success Response (201 Created):Now retrieve the user you just created:You’ll get a list of all users:
The
id field is a UUID that’s automatically generated by the system.Explore the Swagger UI
The API includes interactive documentation powered by Swagger/OpenAPI. Open your browser and navigate to:http://localhost:8080/swagger-ui/index.htmlThe Swagger UI allows you to:
- View all available endpoints
- See request/response schemas
- Test API calls directly from your browser
- Download the OpenAPI specification
Try It Out
Use the “Try it out” button on any endpoint to make test requests without writing curl commands.
Available Endpoints
The API provides the following user management endpoints:| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/users | Register a new user |
| GET | /api/v1/users | Get all users |
| GET | /api/v1/users/{id} | Get user by ID |
| PUT | /api/v1/users/{id} | Update user by ID |
| DELETE | /api/v1/users/{id} | Delete user by ID |
Configuration Options
Using PostgreSQL Instead of H2
If you want to use PostgreSQL for persistent storage, you can configure the database connection using environment variables:Using Docker Compose (Recommended)
For the complete setup with PostgreSQL, create adocker-compose.yml file:
Next Steps
Architecture Guide
Learn about hexagonal architecture, CQRS, and DDD patterns
API Reference
Explore all available API endpoints in detail
Configuration
Deep dive into configuration options and environment variables
Testing
Learn how to run tests and view coverage reports
Troubleshooting
Port 8080 is already in use
Port 8080 is already in use
If port 8080 is already in use, you can change it by setting the
SERVER_PORT environment variable:Java version mismatch
Java version mismatch
This project requires Java 21. If you have multiple Java versions installed, set
JAVA_HOME:Database connection errors
Database connection errors
If you’re using PostgreSQL and seeing connection errors:
- Verify PostgreSQL is running:
pg_isready - Check credentials in environment variables
- Ensure the database exists:
createdb user_db - Check firewall rules for port 5432
Build fails with dependency errors
Build fails with dependency errors
Clear the Gradle cache and rebuild: