Consume REST Services
Thursday, June 13, 2024 in Spring Interview Questions
Consume REST Services RestTemplate Synchronous client WebClient Asynchronous client, part of Spring WebFlux FeignClient Synchronous and declarative client, part of Spring Cloud
@Transactional
Thursday, June 13, 2024 in Spring Interview Questions
@Transactional @Transactional on method means that the entire method will run in a single transaction. If any exception occurs during the execution of this method, the transaction will be rolled back, ensuring data consistency
Interceptor
Thursday, June 13, 2024 in Spring Interview Questions
Interceptor Interceptors in Spring allow you to intercept HTTP requests and responses Step Create a class which implement the HandlerInterceptor interface @Component public class MyInterceptor implements HandlerInterceptor { @Override public boolean …
Exception Handling
Thursday, June 13, 2024 in Spring Interview Questions
Exception Handling @ControllerAdvice Used on a class to make it a global exception handler @ExceptionHandler Used on methods within a @ControllerAdvice class to define the HTTP response for specific exceptions @ControllerAdvice public class …
@CrossOrigin
Thursday, June 13, 2024 in Spring Interview Questions
@CrossOrigin @CrossOrigin enable CORS request on whole controller or certain methods
Authentication, Authorization
Thursday, June 13, 2024 in Spring Interview Questions
Authentication, Authorization Authentication The process of verifying the identity of a user Authorization The process of verifying what an authenticated user is allowed to do
Object-Relational Mapping (ORM)
Thursday, June 13, 2024 in Spring Interview Questions
Object-Relational Mapping (ORM) ORM provides the foundational concept for mapping objects to relational databases Java Persistence API (JPA) standardizes ORM in Java, defining a set of rules and interfaces Hibernate implements JPA, offering the …
Data Binding, Validation
Thursday, June 13, 2024 in Spring Interview Questions
Data Binding, Validation Data Binding @RequestParam @GetMapping("/search") public List<Item> searchItems( @RequestParam(name = "query") String query, @RequestParam(name = "page", required = false, defaultValue = …
Request Mapping
Thursday, June 13, 2024 in Spring Interview Questions
Request Mapping @GetMapping @GetMapping("/users") public ResponseEntity<List<User>> getUsers() { List<User> users = // Fetch users return ResponseEntity.ok(users); } @PostMapping @PostMapping("/users") public …