A comprehensive Java Spring Boot e-commerce store API.
- Development Guide - Hot reload, debugging, and workflow
- Docker Guide - Detailed Docker documentation
- Quick Start Guide - Quick reference
- Stripe Testing Guide - Testing payments without a frontend
Choose one of the following setup options:
Required:
- Java 21
- MySQL 8.0
Installation (macOS):
# Install Java 21
brew install openjdk@21
# Install MySQL
brew install mysql
brew services start mysqlInstallation (Ubuntu):
# Install Java 21
sudo apt update
sudo apt install openjdk-21-jdk
# Install MySQL
sudo apt install mysql-server
sudo systemctl start mysql
sudo systemctl enable mysqlNote: If there are multiple jdk versions on the machine, and you want to run from terminal, use 21.
# .bashrc
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATHthen
./mvnw spring-boot:runOptional:
- DBeaver for database management
- IntelliJ IDEA for development
Required:
Use this option if:
- You don't want to install Java / MySQL locally
- You want an isolated environment
# Connect to MySQL
mysql -u root
# Set root password and create database
ALTER USER 'root'@'localhost' IDENTIFIED BY '0000';
FLUSH PRIVILEGES;
CREATE DATABASE my_store;
EXIT;# Copy environment template
cp .env.example .env
# Generate JWT secret
openssl rand -base64 64
# Edit .env and set JWT_SECRET to the generated valueSet up JDK:
- Go to File > Project Structure > Project
- Set SDK to Java 21
Find JDK location if needed:
# macOS
/usr/libexec/java_home -V
# Ubuntu
ls /usr/lib/jvmCommon locations:
- macOS:
/Library/Java/JavaVirtualMachines/openjdk-21.jdk/Contents/Home - Ubuntu:
/usr/lib/jvm/java-21-openjdk-amd64/
Set up database connection:
- Open Database tab (right side)
- Click + > Data Source > MySQL
- Configure:
- Host:
localhost - Port:
3306 - User:
root - Password:
0000 - Database:
my_store
- Host:
Run migrations:
- Open Maven tool window
- Navigate to Plugins > flyway
- Run
flyway:migrate
Create run configuration:
- Run > Edit Configurations
- Add new Spring Boot configuration
- Select main class:
com.vpe.finalstore.FinalStoreApplication - Run the application
Alternative: Use Make commands:
make start # Start the application locally
make build # Build the application locallyAfter you run the app you can seed the database with test data by running the following command:
curl -X POST -H "Content-Type: application/json" -d '{"cleanStart": true, "userCount": 100, "productCount": 50, "orderCount": 200}' http://localhost:8080/api/seeder/db-seedor via Swagger UI: http://localhost:8080/swagger-ui.html#. Look for /api/seeder/db-seed and /api/seeder/clean
- API: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger-ui.html
Docker Compose sets up both the application and MySQL database with a single command.
# Copy environment template
cp .env.example .env
# Generate JWT secret
openssl rand -base64 64
# Edit .env and set JWT_SECRET to the generated valueDevelopment mode with Docker (hot reload):
make start-devFeatures:
- Automatically reloads when you change Java files
- No rebuild needed after code changes
- Debug port available on 5005
- Useful when you don't have Java installed locally
Production mode with Docker:
make start-prodNote: In production mode, rebuild after code changes:
make build-prodAll available commands:
make helpConnect to MySQL:
# From Docker container
docker exec -it final-store-mysql mysql -uroot -p0000 my_store
# From host machine
mysql -h 127.0.0.1 -P 3307 -u root -p0000 my_storeRun the seed script from here
- API: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger-ui.html
Docker Setup: Flyway migrations run automatically when the application starts. The database schema is created on first startup.
Local Setup: Run migrations manually using:
make migrate # Run migrations
make info-migrate # Check migration statusTroubleshooting: If migrations fail, see DEVELOPMENT.md for repair instructions.
View logs (Docker):
make logs-prod # Production mode
make logs-dev # Development modeStop the application (Docker):
make stop-prod # Production mode
make stop-dev # Development modeDatabase shell (Docker):
make db-shell # Production mode
make db-shell-dev # Development mode