In Spring Data JPA, what does the @Repository annotation indicate?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "It's a data access layer component". @Repository là stereotype annotation đánh dấu lớp thuộc tầng truy cập dữ liệu: nó được component scan đăng ký thành bean vì bản thân là một @Component, và Spring áp cơ chế dịch ngoại lệ, đổi lỗi riêng của JPA hay Hibernate sang DataAccessException; với interface kế thừa JpaRepository, Spring Data tự đăng ký bean nên annotation này thường không bắt buộc, nhưng ý nghĩa vẫn là thành phần tầng dữ liệu. "It's a controller method" sai vì phương thức xử lý yêu cầu được đánh dấu bằng @RequestMapping hoặc @GetMapping trong lớp @Controller. "It's a view template" sai vì template là tệp Thymeleaf hay JSP, không phải lớp Java gắn annotation. "It's a security filter" sai vì filter bảo mật thuộc Spring Security, cấu hình qua SecurityFilterChain.
Cùng phần 2
Spring Beans are managed by which container?Có lời giảiCâu hỏiConsider the following Java code snippet:
public class MyService {
private MyDependency dependency;
public void setDependency(MyDependency dependency) {
this.dependency = dependency;
}
public void performAction() {
dependency.doSomething();
}
}
Which Spring Core Container feature is being demonstrated in this code?Có lời giảiCâu hỏiWhich type of Dependency Injection involves passing dependencies to a class through its constructor?Có lời giảiCâu hỏiCả 21 câu của chủ đề21 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây