Exercises (sample)
@GetMapping("/ping") public String ping() { return "pong"; }
server.port=7070 then open http://localhost:7070/hello.
- Without
@RestController, /hello is not exposed as a REST endpoint — expect 404 / whitelabel error. With the annotation restored, it works again.
- Examples: folder layout, choosing compatible dependency versions, generating
pom.xml, wiring a basic Boot main class.
Self-check
- Client and server are the same machine.
localhost / 127.0.0.1 means “talk to myself.”
- Spring Boot, via the Spring Web starter’s embedded Tomcat, starts when the application runs — you did not install Tomcat separately.
- No. The path comes from
@GetMapping("..."); the method can be named anything legal in Java.