What is Spring?
- It is a lightweight, loosely coupled and integrated framework for developing enterprise applications in java.
- Spring Framework is built on top of two design concepts – Dependency Injection and Aspect Oriented Programming.
Why use Spring.(Features/Advantages)
- Whyto use spring is something more of a combination of desire to do things in an easy, secure and efficient way.
- It’s been noticed a lot of complexity of code is present in development which can be avoided, Such as code to handle transaction, JDBC, interaction with ORM, Exception Handling, Testing and many others.
- Springs provides support for existing J2EE technologies and provide easy and efficient way to do the development.
Some of the features of spring framework are:
- Lightweight and very little overhead of using framework for our development.
- Dependency Injection or Inversion of Control to write components that are independent of each other, spring container takes care of wiring them together to achieve our work.
- Spring IoC container manages Spring Bean life cycle and project specific configurations such as JNDI lookup.
- Spring MVC framework can be used to create web applications as well as restful web services capable of returning XML as well as JSON response.
- Support for transaction management, JDBC operations, File uploading, Exception Handling etc with very little configurations, either by using annotations or by spring bean configuration file.
Some of the advantages of using Spring Framework are:
- Reducing direct dependencies between different components of the application, usually Spring IoC container is responsible for initializing resources or beans and inject them as dependencies.
- Writing unit test cases are easy in Spring framework because our business logic doesn’t have direct dependencies with actual resource implementation classes. We can easily write a test configuration and inject our mock beans for testing purposes.
- Reduces the amount of boiler-plate code, such as initializing objects, open/close resources. JdbcTemplate helps us in removing all the boiler-plate code that comes with JDBC programming.
- Spring framework is divided into several modules, it helps us in keeping our application lightweight. For example, if we don’t need Spring transaction management features, we don’t need to add that dependency in our project.
- Spring framework support most of the Java EE features and even much more. It’s always on top of the new technologies, for example there is a Spring project for Android to help us write better code for native android applications. This makes spring framework a complete package and we don’t need to look after different framework for different requiremen
When to use Spring.