Week 7 Spring Stereotype Annotations Flashcards

1
Q

What are stereotype annotations used for?

A

Stereotype annotations are used for Annotation based configuration

Inside of a Spring-based project, if we have “component scanning” aka annotation scanning, we can make use of special annotations called STEREOTYPE ANNOTATIONS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the purpose of Stereotype Annotations?

A

The purpose of stereotype annotations is to easily register Spring beans and store them into the IoC container (Inversion of control container) for future use in dependency injection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the @Component annotation?

A

@Component: Serves as a generic annotation for registering a class as a Spring bean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the @Service Annotation?

A

@Service: Has the same behavior as @Component. The name of @Component and @Service is the only difference. @Service by convention is meant for classes that contain business logic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the @Repository annotation?

A

@Repository: Serves as an annotation for DAO classes. @Repository does add on additional behavior beyond what @Component and @Service do by introducing what is known as “exception translation”. Exceptions that occur inside of the DAO methods will be “translated” into a Spring specific exception. (Such as DataAccessException)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the @Controller annotation?

A

@Controller: Used to register HTTP controllers. These beans will contain methods mapped to various endpoints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly