Introduction to Spring

If we talk about Java EE development then the biggest buddy that comes into the picture is Spring. So in this article, I am going to cover some brief introduction of Spring framework and then we are going to look why Spring is so popular, and in subsequent articles, I am going to cover more about Spring.

So what is Spring
  • Spring is a Lightweight, Open Source, Free to use application framework that provides comprehensive infrastructure support for developing Java-based enterprise applications. Spring handles the infrastructure and configurations so you can focus on your application.
  • It was written by Rod Johnson in June 2003 and first released under the Apache 2.0 license, And now maintained by Pivotal.
  • Spring has not reinvented everything from the scratch but it has integrated some existing technologies and frameworks like Hibernate, Struts, JSF, EJB, and more in an efficient modular architecture by integrating them very efficiently. You can use what you need and can leave those you don’t need now.

    That’s why some developers also call Spring “A framework of frameworks”, because Spring allows them to use all popular frameworks combinedly.

  • The Spring Framework consists of features organized into about 20 modules. These modules are grouped into Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, Messaging, and Test, as shown in the following diagram.
    spring-modules
  • Lightweight IoC container and Transaction support have also made Spring the best replacement for costly EJB containers.
  • Spring Enables to develop enterprise applications using POJO Programming. By using POJO programming developer don’t need any EJB Container in our Application Server Instead of that only a robust Servlet Container is good. POJO programming also enables continuous integration and testability.

Why Spring is so popular

Spring became so popular in its early days because of these features
  • Lightweight: Spring is lightweight when it comes to size and transparency,
    • The basic version of the spring framework is around 1MB.
    • Processing overhead is also very negligible.
    • Due to its modular architecture, you have the option to choose what you want to include and what’s not.
    • You can also call Spring lightweight as compared to heavyweight EJB containers.
  • Loose Coupled code through Dependency Injection: Loose coupling is achieved in Spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects.
  • Spring Core Container or IoC Container: Central to the Spring framework is its Ioc Container which contains and manages the lifecycle and configuration of application objects. Objects created by the container are also called managed objects or beans.
  • Aspect-oriented Programming (AOP): Spring supports Aspect Oriented Programming and enables cohesive development by separating application business logic from system services.
  • MVC Framework: Spring comes with MVC web application framework (Spring MVC), built on core Spring functionality. This framework is highly configurable via strategy interfaces and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. But other frameworks can be easily used instead of Spring MVC Framework.
  • Transaction Management: Spring provides a declarative transaction management interface that can scale down to a local transaction (using a single database e.g.) and scale up to global transactions (using JTA e.g.). This allows the developer to add the pluggable transaction managers and making it easy to demarcate transactions without dealing with low-level issues. Spring’s transaction support is not tied to J2EE environments and it can be also used in the container-less environments.
  • Convenient Exception Handling: Spring provides a convenient API for translating technology-specific exceptions (thrown by JDBC, Hibernate, or JDO e.g.) into consistent, meaningful, unchecked exceptions which describe more about itself.
Next Post Newer Post Previous Post Older Post Home

2 comments :

  1. hi,
    i am amit, i doing preparing for interview like spring, java,hibernate.so just you guide us

    what kind of questions asking by interviewer?

    ReplyDelete
    Replies
    1. Hi Amit, there are lots of varieties of questions you might face related to Java, Spring and Hibernate.

      Simple google search like `Java interview questions`, `Hibernate interview questions` and `Spring interview questions` will give a list of questions.

      Delete