What are Spring Framework Modules?
Explain the 5 Spring Projects?
What is dependency injection and what are some of the benefits of using dependency injection?
What 2 methods of dependency injection does Spring support?
What are some differences between BeanFactory and ApplicationContext? Which one eagerly instantiates your beans?
What is the Spring Bean lifecycle (12 steps)?
What is bean wiring? What about autowiring?
What are the different ways that Spring can wire beans?
What are the 6 scopes of Spring beans? Which is default?
Describe the purpose of the Spring framework
Spring is a powerful framework that allows us to jump right in to enterprise level application programming. Spring inverts control, helps us achieve loose coupling, and offers robust abstractions/solutions for common needs such as persistence and servlets.
What version of Spring are you comfortable working with? Do you know the latest major version released?
The latest major version is version 5, we are currently using spring boot 2.5.6 which includes spring core 5.3.12.
What is dependency injection?
this is a technique where an object receives other objects it depends on, in the most basic form using constructors and setters
what is inversion of control?
This is a paradigm where program execution and control is handed off to some framework, and our code is invoked by that framework. This inverts the traditional idea of our program beginning with the main method, foolowing our execution, and invoking library methods.
How is dependency injection achieved within the Spring framework?
Spring offers DI by providing the dependencies on demand. The dependencies are beans described to a BeanFactory (an IoC Container) with either XML files, or programatically. Spring will autowire these dependencies in as needed.
What is the primary IoC container in Spring?
BeanFactory, which was supplanted by a class that extends it: ApplicationContext. ApplicationContext also has been extended for more specific use, like WebAwareApplicationContext. There are others as well like AnnotationConfigApplicationContext.
What are some differences between the ApplicationContext and the BeanFactory in Spring?
ApplicationContext extends BeanFactory and contains additional features like messaging and event publication. Also BeanFactory is lazy and ApplicationContext is eager by default.
Are beans loaded eagerly or lazily within the ApplicationContext? How can you change this?
By default they are loaded eagerly. This behavior can be changed with the @Lazy annotation.
What are some ways that a bean registry can be provided to Spring?
We can supply bean descriptions with XML files, or by scanning for properly annotated classes.
What is component-scanning in Spring?
A component is a bean, and component scanning is a method of describing beans where Spring scans through specified packages of classes looking for properly annotated classes that describe beans.
What are the 5 Spring stereotype annotations?
@Component - a generic stereotype used to declare an objects as a bean, which will be injected into other classes/beans at some point in time
@Controller - marks a class as a Spring MVC Controller which allow the use of handler mapping annotations. Classes annotated with @Controller are autodeteced through classpath scanning. when used in comination with @RequestMapping it allows for quick configurations of a web application controller
@Repository - marks a class to be used as a for use with storing data within a repository or database. also provides benefits for objects that would otherwise be utilized as a DAO
@Service - marks a class as a Service for an application
@RestController - a convenience stereotype annotation which combines the features of @RequestMapping with the @ResponseBody annotations. This allows the use of HTTP method specific Mapping annotations which automatically produce an XML, JSON or other response
What is the difference between manual bean wiring and autowiring?
The @Autowired annotation is used to have Spring grab necessary dependencies from the IoC container and inject them.
Manual wiring is requesting a bean by type or name yourself and assigning it to a reference.
What is the standard lifecycle of a bean within the ApplicationContext?
Instantiation, awareness, initialization (including custom init methods), post-init-processing, in-use, destruction (including custom destory methods), garbage collection.
What are the scopes of a Spring bean? What is the default?
Singleton (DEFAULT) and Prototype are the basic ones. There are also other used for specific ApplicationContexts, like request, session, and global session scopes.