Câu hỏi phỏng vấn Spring
Câu hỏi

What are the differe...

Câu trả lời

In Spring Aspect-Oriented Programming (AOP), an advice is an action taken by an aspect at a particular join point. There are five types of advices in Spring AOP:

  1. Before Advice: This type of advice runs before the advised method is invoked. It is typically used to perform certain actions before a method execution, such as logging, security checks, or input validation. It is denoted by the @Before annotation[1][3].

  2. After Advice: Also known as "after finally" advice, it runs after the advised method execution, regardless of its outcome, meaning it will execute whether the method completes successfully or if it throws an exception. This advice is useful for actions that need to occur no matter what the method outcome is, like releasing resources or logging. It is denoted by the @After annotation[1][3].

  3. After Returning Advice: This advice runs after the advised method executes successfully, i.e., it does not throw an exception. It is often used for post-processing the return value of a method, such as modifying the result or logging. It is denoted by the @AfterReturning annotation[1][3].

  4. After Throwing Advice: This advice is executed if the advised method exits by throwing an exception. It is useful for exception handling and logging, allowing developers to react to an exception being thrown. It is denoted by the @AfterThrowing annotation[1][3].

  5. **Around...

senior

senior

Gợi ý câu hỏi phỏng vấn

junior

What is Spring Boot?

middle

What is Aspect?

middle

Why are controllers testable artifacts?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào