Windows IntelliJ Guide: Logistics Service Setup - Wiz-DevTech/prettygirllz GitHub Wiki

Here's a step-by-step guide for Windows users using IntelliJ IDEA to implement the Logistics Service:


Windows/IntelliJ Guide: Logistics Service Setup

(With Screenshot References)

1. Prerequisites Installation

1.1 Install Required Software

  1. Java 17+

    • Download from Adoptium

    • Run installer → Add to PATH during installation

    • Verify:

      cmd
      Copy
      Download
      java -version
  2. IntelliJ IDEA

  3. Docker Desktop

    • Download from Docker Hub

    • Enable WSL 2 Backend during installation

    • Post-install: Right-click tray icon → Settings → Resources → Set RAM ≥4GB

  4. Git

    cmd
    Copy
    Download
    winget install --id Git.Git -e

2. Project Setup in IntelliJ

2.1 Clone Repository

  1. In IntelliJ:
    File → New → Project from Version Control

    text
    Copy
    Download
    URL: https://github.com/your-org/logistics-service.git
    Directory: C:\Users\{YourUser}\logistics-service
  2. Trust Project when prompted

2.2 Configure SDK

  1. File → Project Structure (Ctrl+Alt+Shift+S)

  2. Under Project Settings → Project:

    • Set SDK: Java 17

    • Set Language Level: 17


3. Docker Setup

3.1 Start Containers

  1. Open Terminal in IntelliJ (Alt+F12)

  2. Run:

    powershell
    Copy
    Download
    docker-compose up -d postgres kafka redis
  3. Verify Containers:

    • Open Docker Desktop → Containers tab

    • Should show 3 containers running

Docker Desktop view

Troubleshooting:

  • If ports conflict (e.g., 5432 already used):

    powershell
    Copy
    Download
    netstat -ano | findstr :5432
    taskkill /PID {PID} /F

4. Database Initialization

4.1 Connect to PostgreSQL

  1. In IntelliJ:
    View → Tool Windows → Database

  2. Click + → Data Source → PostgreSQL

    text
    Copy
    Download
    Host: localhost
    Port: 5432
    User: postgres
    Password: postgres
    Database: logistics
  3. Test Connection → Apply

4.2 Run SQL Script

  1. Right-click project → New → File named init_db.sql

  2. Paste the schema from original guide

  3. Right-click the script → Run


5. Run the Application

5.1 Configure Run/Debug

  1. Locate LogisticsApp.java

  2. Click gutter icon next to main()  Run

  3. First Run Fixes:

    • If missing dependencies:
      Right-click project → Maven → Reload Project

    • If Lombok errors:
      File → Settings → Build → Compiler → Annotation Processors → Enable

5.2 Environment Variables

  1. Go to Run → Edit Configurations

  2. Under Environment Variables:

    text
    Copy
    Download
    SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/logistics
    SPRING_DATASOURCE_USERNAME=postgres
    SPRING_DATASOURCE_PASSWORD=postgres

6. Testing in IntelliJ

6.1 Unit Tests

  1. Open any test file (e.g., DeliveryServiceTest.java)

  2. Click Run Test gutter icon

6.2 API Testing

  1. Install HTTP Client plugin if missing

  2. Create rest_test.http file:

    http
    Copy
    Download
    POST http://localhost:8080/api/v1/deliveries
    Content-Type: application/json
    
    {
      "orderId": "win_test_1",
      "destinationType": "OFFICE"
    }
  3. Click Run icon in the gutter


7. Debugging Tips

Common Issues & Fixes

Problem | Solution -- | -- "Port already in use" | Run: Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess -Force Docker errors | In Docker Desktop → Troubleshoot → Restart Lombok warnings | Install plugin: File → Settings → Plugins → Lombok

Log Navigation

  • Use Search (Ctrl+F) in Run console tab

  • Filter by log level:

IntelliJ log filtering


Next Steps

  1. Set Breakpoints: Click gutter next to line numbers

  2. Step Through Code: Use Debug mode (Shift+F9)

  3. Monitor Containers: Use Docker Desktop's Logs tab

Pro Tip: Bookmark IntelliJ shortcuts:

  • Alt+1: Project view

  • Ctrl+Shift+F10: Run current file

  • Ctrl+Shift+A: Find any action

Here's a step-by-step guide for Windows users using IntelliJ IDEA to implement the Logistics Service:

Windows/IntelliJ Guide: Logistics Service Setup (With Screenshot References)

  1. Prerequisites Installation 1.1 Install Required Software Java 17+

Download from Adoptium

Run installer → Add to PATH during installation

Verify:

cmd java -version IntelliJ IDEA

Download Community Edition

Install with .java and .sh file associations

Docker Desktop

Download from Docker Hub

Enable WSL 2 Backend during installation

Post-install: Right-click tray icon → Settings → Resources → Set RAM ≥4GB

Git

cmd winget install --id Git.Git -e 2. Project Setup in IntelliJ 2.1 Clone Repository In IntelliJ: File → New → Project from Version Control

text URL: https://github.com/your-org/logistics-service.git Directory: C:\Users{YourUser}\logistics-service Trust Project when prompted

2.2 Configure SDK File → Project Structure (Ctrl+Alt+Shift+S)

Under Project Settings → Project:

Set SDK: Java 17

Set Language Level: 17

  1. Docker Setup 3.1 Start Containers Open Terminal in IntelliJ (Alt+F12)

Run:

powershell docker-compose up -d postgres kafka redis Verify Containers:

Open Docker Desktop → Containers tab

Should show 3 containers running

Docker Desktop view

Troubleshooting:

If ports conflict (e.g., 5432 already used):

powershell netstat -ano | findstr :5432 taskkill /PID {PID} /F 4. Database Initialization 4.1 Connect to PostgreSQL In IntelliJ: View → Tool Windows → Database

Click + → Data Source → PostgreSQL

text Host: localhost Port: 5432 User: postgres Password: postgres Database: logistics Test Connection → Apply

4.2 Run SQL Script Right-click project → New → File named init_db.sql

Paste the schema from original guide

Right-click the script → Run

  1. Run the Application 5.1 Configure Run/Debug Locate LogisticsApp.java

Click gutter icon next to main() → Run

First Run Fixes:

If missing dependencies: Right-click project → Maven → Reload Project

If Lombok errors: File → Settings → Build → Compiler → Annotation Processors → Enable

5.2 Environment Variables Go to Run → Edit Configurations

Under Environment Variables:

text SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/logistics SPRING_DATASOURCE_USERNAME=postgres SPRING_DATASOURCE_PASSWORD=postgres 6. Testing in IntelliJ 6.1 Unit Tests Open any test file (e.g., DeliveryServiceTest.java)

Click Run Test gutter icon

6.2 API Testing Install HTTP Client plugin if missing

Create rest_test.http file:

http POST http://localhost:8080/api/v1/deliveries Content-Type: application/json

{ "orderId": "win_test_1", "destinationType": "OFFICE" } Click Run icon in the gutter

  1. Debugging Tips Common Issues & Fixes Problem Solution "Port already in use" Run: Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess -Force Docker errors In Docker Desktop → Troubleshoot → Restart Lombok warnings Install plugin: File → Settings → Plugins → Lombok Log Navigation Use Search (Ctrl+F) in Run console tab

Filter by log level:

IntelliJ log filtering

Next Steps Set Breakpoints: Click gutter next to line numbers

Step Through Code: Use Debug mode (Shift+F9)

Monitor Containers: Use Docker Desktop's Logs tab

Pro Tip: Bookmark IntelliJ shortcuts:

Alt+1: Project view

Ctrl+Shift+F10: Run current file

Ctrl+Shift+A: Find any action

⚠️ **GitHub.com Fallback** ⚠️