
Spring


What is Spring?
The Spring framework is an open-source Java application framework, which is based on two key principles: dependency injection and Inversion of Control. Spring has the ability to autowire the dependency at run time, which allows the developer to write loosely coupled code.
Spring framework uses metadata in the form of xml file or java annotations to create objects and identifies dependencies, thereby producing a ready-to-use application.
A typical web application is divided into three layers: web, business, and the data layer. These layers have objects that collaborate with each other to make the application work. These collaborations are called dependencies. A typical application has a lot of classes and dependencies.
Spring Framework heavily relies on the principle of Loose Coupling, creating objects and populates it with dependencies that are needed. You as programmer only need to tell which objects need to create and what are their dependencies of these objects, and Spring inverts the control of populating the dependencies injecting them into the objects. THis is referred as Inversion of Control (IoC).
In resume, Spring is a powerful dependency injection framework that promotes the development of loosely coupled code.


Spring Topics
- Terminology
- Spring
- Spring boot

Latest Java learning
- Mixing Bean Scopes – Proxy and @LookupIs possible that in your design you will encounter situations where beans have the Singleton Scope but dependencies on beans with the Prototype scope. Spring has several ways to handle this problem: Proxy and @Lookup
- Bean Scopes – Singleton and PrototypeSpring 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 – @QualifierSpring 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 NameAutowiring 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.
- Autowiring By Type – @PrimarySpring has several ways to do the dynamic autowiring, una de ellas es el autowiring by Type using the @Primary annotation.
- Managing Beans and DependenciesSpring 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 ProjectBuilding 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 ArchitectureBesides 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 TerminologyWhen 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.
- Creating RESTful Web Services with Spring bootTo Create a REST Project, the best way to create a Spring boot project is using the Spring Initializr start.spring.io
