Spring Into New Territory

The Spring Framework is basically the superset of all things Spring.


What is Spring?


All programming done in Spring Boot, Spring Data, Spring Batch all build on top of the Spring

 Framework. 


Further, it also provides support for various other frameworks as well, such as Hibernate, 

Tapestry, JSF, etc.


​It is important that you are familiar with the Spring Framework prior to programming with 

any other projects as having the core knowledge of the framework would be beneficial in 

programming. 


Spring is a lightweight framework and can be basically defined as a dependency injection 

container with aspects that aid in efficient programming in Java.


What is a Dependency Injection?


This is the method by which an object receives a dependency. The client, the object which 

receives the passed object or the dependency, which is referred to as the service in this 

context. The code or object that is passed is called the injector.


In the most general sense, a dependency injection means that an object is passed to a method 

as a parameter rather than it being created as a dependent object in the method. That way, 

the method is not inherently dependent on one particular implementation. Any 

implementation that meets the requirements of the parameter can be passed into the method.


When there are many methods that require the same dependencies, it is still necessary that 

the programmer manually sets the dependencies. Even though, the code may be optimized, 

there is still the necessity for the programmer to construct a class and set a dependency.


The Spring Framework is able to perform these functions for the programmer as it is a 

dependency injection container. It is able to manage the classes that have been written and 

the dependencies.


This allows the code to be loosely coupled and aids in simplifying testing.


In the world of the Spring Framework, the controller of the classes and dependencies, is 

known as the ApplicationContext.


There are various methods by which Spring ApplicationContext can be constructed. It can be 

done with the program, annotated through Java configuration classes, or through XML files.



Benefits of Spring


1. It is a lightweight framework

2. Can be constructed with XML or within the Java code

3. Enables loose coupling through dependency injection and inversion of control

4. Provides support for testing code

5. Enables modular programming

6. Enables development with the use of the POJO and POJI based-model





Comments

Popular Posts