Spring framework Flashcards

1
Q

What stereotype annotations are there in spring?

A
  • @Component - generic
  • @Controller - controller in spring mvc web app
  • @Service - class in business layer
  • @Repository - class working with spring data repositories
  • @Configuration - class with @Beans
  • @RestController - specialised controller combining @Controller & @ResponseBody
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How could you add a bean for test purposes in spring?

A
  • create a @TestConfiguration class
  • explicitly @Import into test class as this type of stereotype isn’t picked up by component scanning and so won’t be picked up by other test classes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is IOC in the spring framework?

A

inversion of control - the ioc container manages the lifecycle of beans in the conxtext, instead of in the app.

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

What is DI in spring?

A

When the ioc container injects dependencies from the context into the bean via e.g constructor injection.

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

What is component scanning in spring?

A
  • telling spring what paths to look at for picking up annotated classes
  • default paths can be defined and packaged excluded
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Messaging Gateway?

A

A messaging gateway typically acts as a translation mechanism, abstracting the details of formatting, protocols, and message transfer to enable communication between different systems by ensuring compatibility and understanding on the receiving end.

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