Spring 2 Flashcards

1
Q

when are annotations processed?

A

compile or runtime.

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

why use annotations?

A

XML config can be very verbose. Annotations allow you to minimize the xml configuration.

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

how do annotations work?

A

when you add annotations to a class, spring will scan your classes for special annotations. when it finds one, it will automatically register that bean with the spring container.

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

what is autowiring?

A

Autowiring feature of spring framework enables you to inject the object dependency implicitly. You can use the annotation on setter methods to get rid of the element in XML configuration file.

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

types of autowiring

A
  • constructor injection
  • setter injection
  • field injections
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

field injection development process

A

Configure the dependency injection with the @Autowired annotation (applied directly to the field and you do not need setter methods).

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

specify bean scope annotation

A

@Scope(“singleton”)

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

annotations for bean init & best destruction

A

@PostConstruct & @PreDestroy

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

development process for bean init & best destruction

A
  1. define methods for init & destroy
  2. add the @PreDestroy & @PostConstruct annotations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly