Option A: Using Homebrew (Recommended for macOS)
# Install Homebrew if not installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Java 17
brew install openjdk@17
# Link Java
sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk
# Add to PATH (add to ~/.zshrc)
echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcOption B: Download from Oracle
- Visit: https://www.oracle.com/java/technologies/downloads/
- Download JDK 17 for macOS
- Install the .dmg file
# Using Homebrew
brew install mavenjava -version # Should show Java 17.x.x
mvn -version # Should show Maven 3.x.xcd /Users/pritikavipin/Documents/SpringBootRestAPI
# Clean and build
mvn clean package -DskipTests
# Run the application
mvn spring-boot:run-
Install Extensions:
- Extension Pack for Java (by Microsoft)
- Spring Boot Extension Pack (by VMware)
-
Open Project:
- Open the
SpringBootRestAPIfolder in VS Code - Wait for Java extensions to load
- Open the
-
Run Application:
- Open
GeospatialAnalysisApplication.java - Click "Run" or "Debug" button above the
mainmethod - Or press F5 to debug
- Open
-
Open Project:
- File → Open → Select
SpringBootRestAPIfolder - Wait for Maven import to complete
- File → Open → Select
-
Run Application:
- Navigate to
GeospatialAnalysisApplication.java - Right-click → Run 'GeospatialAnalysisApplication'
- Navigate to
Once running, test the API:
# Check if server is running
curl http://localhost:8080/api/regions
# Create a test region
curl -X POST http://localhost:8080/api/regions \
-H "Content-Type: application/json" \
-d '{
"name": "Test Region",
"latitude": 37.7749,
"longitude": -122.4194,
"description": "Test description"
}'# Check JAVA_HOME
echo $JAVA_HOME
# Set JAVA_HOME if empty (add to ~/.zshrc)
export JAVA_HOME=$(/usr/libexec/java_home -v 17)# Install via Homebrew
brew install maven# Find process using port 8080
lsof -i :8080
# Kill the process
kill -9 <PID>
# Or change port in application.properties
server.port=8081After the application starts successfully:
- Access H2 Console: http://localhost:8080/h2-console
- Test API endpoints using the examples in README.md
- Use tools like Postman or curl to interact with the API