Spring Boot

Exception Handling

Exception handling with @ControllerAdvice, @ExceptionHandler, @ResponseStatus, error standardization

25 คำถามสัมภาษณ์·
Mid-Level
1

What is @ControllerAdvice in Spring MVC?

คำตอบ

@ControllerAdvice allows centralizing exception handling for all application controllers. This annotation creates a global component that intercepts exceptions thrown by any @Controller or @RestController. This avoids duplicating error handling logic in each controller and promotes error response consistency.

2

How to handle a specific exception in a controller?

คำตอบ

@ExceptionHandler allows defining a method that handles one or more specific exceptions in a controller or @ControllerAdvice. The annotated method is automatically invoked when the specified exception is thrown. It's possible to return a ResponseEntity to control the HTTP status and response body.

3

What is the purpose of @ResponseStatus on an exception class?

คำตอบ

@ResponseStatus on a custom exception allows automatically mapping this exception to a specific HTTP status code. When the exception is thrown, Spring automatically returns the indicated HTTP status without requiring an @ExceptionHandler. This approach simplifies code for simple exceptions that directly correspond to an HTTP status.

4

Which exception is thrown when validation with @Valid fails?

5

What is ProblemDetail in Spring 6+?

+22 คำถามสัมภาษณ์

หัวข้อสัมภาษณ์ Spring Boot อื่นๆ

Spring Core - IoC & DI

Junior
22 คำถาม

Spring Boot Auto-Configuration

Junior
20 คำถาม

Spring Boot Starters

Junior
18 คำถาม

Application Properties & YAML

Junior
16 คำถาม

Logging with SLF4J & Logback

Junior
20 คำถาม

Spring Boot DevTools

Junior
15 คำถาม

Spring MVC Basics

Mid-Level
20 คำถาม

Spring REST Controllers

Mid-Level
20 คำถาม

Request & Response Handling

Mid-Level
20 คำถาม

Bean Validation

Mid-Level
25 คำถาม

Spring Data JPA Basics

Mid-Level
25 คำถาม

JPA Entities & Relationships

Mid-Level
30 คำถาม

JPA Queries

Mid-Level
30 คำถาม

Spring Data Repositories

Mid-Level
25 คำถาม

Spring Security Basics

Mid-Level
25 คำถาม

Spring Boot Actuator

Mid-Level
20 คำถาม

Unit Testing with JUnit & Mockito

Mid-Level
30 คำถาม

Spring Boot Testing

Mid-Level
30 คำถาม

Profiles & Environment

Mid-Level
20 คำถาม

RestTemplate & WebClient

Mid-Level
24 คำถาม

Async & Scheduling

Mid-Level
25 คำถาม

Caching with Spring

Mid-Level
25 คำถาม

Spring WebFlux (Reactive)

Mid-Level
25 คำถาม

Spring Transactions

Senior
30 คำถาม

Advanced Authentication & Authorization

Senior
30 คำถาม

JWT & Stateless Security

Senior
20 คำถาม

OAuth2 & Authorization Server

Senior
20 คำถาม

Spring Boot & Docker

Senior
19 คำถาม

Microservices with Spring

Senior
25 คำถาม

Spring Cloud Config

Senior
19 คำถาม

Performance Optimization

Senior
30 คำถาม

GraalVM Native Images

Senior
20 คำถาม

เชี่ยวชาญ Spring Boot สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี