Skip to main content
This guide walks you through setting up the Ecommerce API on your local machine.

Prerequisites

Before you begin, ensure you have the following installed:
  • Java 17 or higher
  • Maven 3.6+ (or use the included Maven wrapper)
  • PostgreSQL (or H2 for development)

Database Configuration

The API supports both PostgreSQL for production and H2 for local development.
# src/main/resources/application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/ecommerce
spring.datasource.username=your_username
spring.datasource.password=your_password

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
The H2 console is available at http://localhost:8080/h2-console when enabled.

Application Properties

The application comes with default configuration values:
application.properties
spring.application.name=ecommerce
spring.data.web.pageable.default-page-size=20
spring.data.web.pageable.max-page-size=50

Configuration Parameters

spring.application.name
string
default:"ecommerce"
The application name identifier
spring.data.web.pageable.default-page-size
integer
default:"20"
Default number of items returned per page when not specified
spring.data.web.pageable.max-page-size
integer
default:"50"
Maximum allowed page size to prevent excessive data retrieval

Installation Steps

1

Clone the Repository

Clone the project to your local machine:
git clone <repository-url>
cd ecommerce
2

Configure Database

Edit src/main/resources/application.properties with your database credentials:
spring.datasource.url=jdbc:postgresql://localhost:5432/ecommerce
spring.datasource.username=your_username
spring.datasource.password=your_password
Create the database:
createdb ecommerce
3

Build the Project

Use Maven to build the project and download dependencies:
./mvnw clean install
The Maven wrapper (./mvnw) is included in the project and doesn’t require a system-wide Maven installation.
4

Run the Application

Start the Spring Boot application:
./mvnw spring-boot:run
The API will start on http://localhost:8080
5

Verify Installation

Test the API is running:
curl http://localhost:8080/products
You should receive a paginated response with products.

Environment Variables

You can override properties using environment variables:
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/ecommerce
export SPRING_DATASOURCE_USERNAME=admin
export SPRING_DATASOURCE_PASSWORD=secretpassword

./mvnw spring-boot:run
Never commit sensitive credentials to version control. Use environment variables or external configuration for production deployments.

Development Mode

The project includes Spring Boot DevTools for automatic restarts during development:
pom.xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>
Changes to Java files will automatically trigger an application restart.

Next Steps

Authentication

Learn about user creation and security configuration

Pagination

Understand how to work with paginated endpoints

Build docs developers (and LLMs) love