Ans: With Dependency Injection, there is no need for you to create your objects. Nevertheless, you need to give a description of how you want them to be created. Here, the developer doesn’t connect the components and services together directly in the code. Instead of that, he has to describe the services that are required by the components in the configuration file. After that, the IoC container is going to wire them up together.
It is a key aspect of the Spring framework that injects objects into dependencies or other objects. In other words, this enables the loose coupling of components.
Ans: In total, there are five scopes that are supported by the Spring Framework.
Remember, if you use a web-aware ApplicationContext, only then you can use the last three.
Ans: This module is kind of separate from the Spring framework. The aim of Spring security is to give authentication and authorization techniques in Java applications. Not only that, it handles frequent security vulnerabilities like CSRF attacks.
This type of authentication is powerful and customizable. This access-control framework is the de-facto standard that ensures safety to the Spring-based applications.
In order to use the Spring Security framework in any of the web applications, there is a simple way to get started. All you have to do is to use a basic annotation .i.e, @EnableWebSecurity, and you are good to go.
Ans: There are huge differences between BeanFactory and ApplicationContext. The example to highlight their difference is everywhere on the internet. However, we will briefly tell you the points that make them different from one other.
BeanFactory is a simple container with insubstantial functionality. It doesn’t occupy too much space which can be a positive feature of this container. Due to the limited functions, you can utilize it to perform basic tasks or when you are working on low-resource machines. We suggest using BeanFactory when you have less memory left on the system.
The ApplicationContext is an advanced container with an improved interface and added capabilities, such as AOP. hence, you can use it for the task that requires more functionality.
Ans: It won’t be incorrect to say that beans are the backbone of the user’s application. As mention previously, the Spring IoC container is responsible for managing them, instantiating, wiring them together, and configuring them. The configuration metadata that the developer sends to the container creates beans.
On the other hand, Java Bean is serializable and is not managed by the Ioc container. Interestingly, at the same time, a Java object may exist in the form of a JavaBean, a POJO, and a Spring bean. This is something that a Spring bean is not able to do.
|