Spring framework Flashcards
What stereotype annotations are there in spring?
- @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 could you add a bean for test purposes in spring?
- 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
What is IOC in the spring framework?
inversion of control - the ioc container manages the lifecycle of beans in the conxtext, instead of in the app.
What is DI in spring?
When the ioc container injects dependencies from the context into the bean via e.g constructor injection.
What is component scanning in spring?
- telling spring what paths to look at for picking up annotated classes
- default paths can be defined and packaged excluded
What is a Messaging Gateway?
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.