Prerequisites
Before you begin, ensure you have the following installed:Java 8+
JDK 8 or higher required
Gradle 5.6
Build automation tool (wrapper included)
Docker
For running MySQL, RabbitMQ, and Zipkin
Git
Version control
Infrastructure Setup
The service depends on shared infrastructure components from the devops repository.Clone Devops Repository
First, clone and setup the devops repository:Start RabbitMQ
RabbitMQ is required for event publishing:RabbitMQ only needs to be started once for all Ecommerce microservices. It will continue running until you stop it.
- Management UI: http://localhost:15672
- Username:
guest - Password:
guest
Start Zipkin
Zipkin provides distributed tracing:- Zipkin UI: http://localhost:9411
Project Setup
Clone the Repository
Project Structure
The project is organized into two modules:Build the Project
Use the Gradle wrapper to build:- Compile all source code
- Run unit tests
- Run component tests
- Run API tests
- Generate build artifacts
The first build may take several minutes as Gradle downloads dependencies.
IDE Setup
IntelliJ IDEA
The project includes a script to generate IntelliJ project files:- Generate IntelliJ IDEA project files
- Configure Gradle integration
- Automatically open IntelliJ IDEA
- Open IntelliJ IDEA
- File → Open
- Select the
ecommerce-order-servicedirectory - Choose “Open as Gradle Project”
Lombok Configuration
The project uses Lombok to reduce boilerplate code:- Install the Lombok plugin in IntelliJ:
- Settings → Plugins → Search “Lombok” → Install
- Enable annotation processing:
- Settings → Build, Execution, Deployment → Compiler → Annotation Processors
- Check “Enable annotation processing”
Running the Service
Using the Run Script
The simplest way to run the service:- Start MySQL via Docker Compose (port 13306)
- Wait for MySQL to be ready
- Start the Spring Boot application (port 8080)
- Enable remote debugging (port 5005)
Manual Start
If you prefer to start components separately:Verify the Service
Once started, verify the service is running:Development Workflow
Make Code Changes
- Edit code in your IDE
- Save changes
- Restart the application to see changes
Run Tests
- All tests
- Unit tests only
- Component tests
- API tests
Clean and Rebuild
Debugging
Remote Debugging
When you run the service with./run.sh, it listens on port 5005 for debugger connections.
IntelliJ IDEA Setup:
- Run → Edit Configurations
- Add New Configuration → Remote JVM Debug
- Set host:
localhost - Set port:
5005 - Click Debug to attach
Viewing Logs
Logs are written to:- Console: stdout/stderr
- File:
/var/log/ecommerce-order-backend/order-dev.log(configured in application-dev.yml)
Common Issues
Port 8080 already in use
Port 8080 already in use
Another application is using port 8080.Solution:Find and stop the process:
RabbitMQ connection refused
RabbitMQ connection refused
RabbitMQ is not running or not accessible.Solution:
- Ensure RabbitMQ is started from devops repository
- Verify it’s accessible at
localhost:5672 - Check Docker containers:
docker ps | grep rabbitmq
MySQL connection error
MySQL connection error
MySQL container is not running or port 13306 is blocked.Solution:
Build fails with 'Lombok not found'
Build fails with 'Lombok not found'
Lombok annotation processing is not enabled.Solution:
- Install Lombok plugin in your IDE
- Enable annotation processing in IDE settings
- Rebuild project:
./gradlew clean build
Next Steps
Configuration
Learn about configuration options
Testing
Understand the testing strategy
API Reference
Explore the REST API
Architecture
Understand the system design