Spring Boot uses annotations to reduce boilerplate code and make development faster. Instead of writing XML configuration, we use simple annotations to configure our application ..
Types of annotation
@SpringBootApplication
@RestController
@RequestMapping
@GetMapping
@PostMapping
@PutMapping
@DeleteMapping
@pathvariables
*@SpringBootApplication *
SpringBootApplication is the main annotation used to start a Spring Boot application.
@RestController
@RestController is used to create RESTful web services (APIs).
*@RequestMapping *
Maps HTTP requests to a class or method; used to define a base URL or endpoint
@GetMapping
Handles HTTP GET requests to retrieve data from the server.
@PostMapping
Handles HTTP POST requests to create new data on the server.
@PutMapping
Handles HTTP PUT requests to update existing data.
@DeleteMapping
Handles HTTP DELETE requests to remove data from the server
** @PathVariable**
Used to extract values from the URL and pass them as method parameters
Quick One-Line Summary
@SpringBootApplication → Start & configure app
@RestController → Create REST APIs
@RequestMapping → Define URL path
@GetMapping → Read data
@PostMapping → Create data
@PutMapping → Update data
@DeleteMapping → Delete data
@PathVariable → Get value from URL
Top comments (0)