Bean Scopes – Singleton and Prototype

Spring has six types of scopes: singleton, prototype, request, session, application, and websocket.
Singleton and Prototype are the two scopes that can be used in any application meanwhile the other four scopes are only available for a web application. For this entry we only focus on the Singleton and Prototype.

Autowiring – @Qualifier

Spring has another a annotation that we can use when we have multiple beans to inject in a dependency, this annotation is @Qualifier. This annotation gives priority to one bean over others if two o more beans of the same type are found.

Autowiring By Name

Autowiring by Name is an approach, while creating an bean, the dependency is injected by matching the name of the reference variable to the bean name. This means that the developer has to ensure that the variable name is the same as its bean.

Managing Beans and Dependencies

Spring automates the process of creating objects and binding them together. Spring takes the responsibility of creating instances of classes and binding the instances based on their dependencies. The instances or objects that Spring manages are called beans. But, how Spring manages objects and dependencies, well, Spring requires information about three things: Beans, Dependencies, and Location of the Beans

Creation of a Spring Project

Building a Spring project from the scratch can be a very challenging process. This is because the developers need to decide which dependencies the project will use, and then they need to build and set up the application infrastructure, such as the configuring the XML configuration file, install and configure Java, install an application server such as Tomcat, Weblogic, WebSphere, etc. This is the nightmare of the configuration because if we miss or configure something incorrectly, we will encounter numerous errors that will require a significant amount of time and effort to correct.

Spring Architecture

Besides of the Spring terminology, when we start with Spring we start to hearing about Spring boot, Spring Cloud, Spring MVC, Spring AOP, etc. and then we don't know how to start and in the worst of the case we drop it to learn it. So, we can continue explaining those modules, project, etc. so let's begin with the Spring Architecture.

Spring Terminology

When we start the Spring Framework, we start listening terms like Beans, Autowiring, Dependency Injection, IoC Factory, Inversion of Control, Application Context, etc. Before the go in full with Spring we need to understand them before.