Using Inspectr with Java Spring
Inspectr works seamlessly with Java Spring Boot applications, making it easy to debug API calls, inspect HTTP traffic, and expose your local service to the internet for webhook testing or integration with external systems.
This guide walks you through running Inspectr in front of a Spring Boot API.
Prerequisites
Section titled “Prerequisites”- Java 17+ and Maven installed
- A Spring Boot project (e.g. using Spring Initializr)
- Inspectr installed (Install guide →)
Step 1: Create or Start a Spring Boot App
Section titled “Step 1: Create or Start a Spring Boot App”You can quickly create a new Spring Boot app:
curl https://start.spring.io/starter.zip \ -d dependencies=web \ -d name=DemoApi \ -o demo.zipunzip demo.zip && cd DemoApi./mvnw spring-boot:run
By default, Spring Boot listens on:
http://localhost:8080
Step 2: Run Inspectr on a Different Port
Section titled “Step 2: Run Inspectr on a Different Port”To avoid conflicts with Spring Boot’s default port, run Inspectr on a different port and forward to your Spring backend:
inspectr --listen=:8181 --backend=http://localhost:8080
Now you can access your Spring API via Inspectr at:
http://localhost:8181
Example:
curl http://localhost:8181/api/hello
All traffic will be logged and shown in the Inspectr App at http://localhost:4004.
Optional: Expose Your Spring Boot API Publicly
Section titled “Optional: Expose Your Spring Boot API Publicly”Run Inspectr with Ingress enabled to expose your API to external services:
inspectr \ --listen=:8181 \ --backend=http://localhost:8080 \ --expose \ --channel=spring-demo \ --channel-code=spring123
Your API will now be available at:
https://spring-demo.in-spectr.dev
Step 3: Debugging with Inspectr
Section titled “Step 3: Debugging with Inspectr”- View requests/responses in real time
- Replay requests to your Spring controllers
- Capture external events (e.g., webhooks) and forward them into your API
Summary
Section titled “Summary”With Inspectr and Spring Boot, you can:
- Debug and inspect HTTP traffic between clients and your backend
- Safely expose your local API for integration testing
- Replay traffic and simulate events using the Inspectr App