if you are looking to get ip address from servlet, inject HttpServletRequest and call in request.getRemoteAddr() method.
and if you're using reverse proxy request, check out this answer's comment https://stackoverflow.com/a/29910902/8733302
@RestController
public class HelloController {
@Autowired
private HttpServletRequest request;
@PostMapping("/coolendpointTWO")
public String withRequestBody(@RequestBody MyPojo myPojo) {
System.out.println("received object" + myPojo);
//handle myPojo with my business logic
String ip = request.getRemoteAddr();
return "good: " + ip;
}
}