Careeroza
Real World Example
Day One on a Real Project
When you join a team at a company like Razorpay or an IT services project, your first task is usually "clone the repo and get the service running locally". The steps are the same as for ShopEase:
git clonethe repository.- Check
pom.xmlfor the Java version (java.version) and install that JDK. - Run
./mvnw clean verifyto download dependencies and run tests. - Read
application.ymlfor required settings (database URL, API keys) and set local values. - Run the main class and hit
/actuator/healthor a simple GET endpoint.
ShopEase Health Check
package com.shopease;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PingController {
@GetMapping("/ping")
public Map<String, String> ping() {
return Map.of("status", "UP", "service", "shopease");
}
}Example
curl http://localhost:8080/pingExample output
{"status":"UP","service":"shopease"}Practice
Exercise: Create a /version endpoint that returns {"app":"shopease","version":"0.0.1"}. Which package must the controller be in?
Show answer
package com.shopease; // same package as ShopeaseApplication, or a sub-package
@RestController
public class VersionController {
@GetMapping("/version")
public Map<String, String> version() {
return Map.of("app", "shopease", "version", "0.0.1");
}
}