Different Types of annotation in spring boot
@RequestMapping
In Spring boot we have different types of annotation , annotation means meta data which have some specific meaning @RequestMapping annotation do specific work if you have 2 to 3 method in a controller then you are hitting the common request in the 3 method like ex emp/Id, emp/CreateEmpolyee then you can give a do emp as parent of that controller and @RequestMapping annotation will help you to do so, you just have to do
@RestController
@RequestMapping(path = "/emp")
public class EmployeeController {
@Autowired
private EmployeeServiceImp employeeServiceImp;
@GetMapping("/{id}")
public Optional<EmployeeEntity> getEmployeeById(@PathVariable long id){
return employeeServiceImp.getEmployeeById(id);
}
}
This is the example where i have a parent Mapping so that i don’t have to put again and again emp in my Http request in the controller.