Spring 4

Spring 4 Tutorial – a Step to New Spring Era

In this series of Spring 4 tutorial we will learn spring 4 framework with examples. Actually Spring 4 is like a new spring era for IT Industry from Spring community.

The Spring Framework was first released in 2004; since then there have been significant major revisions: Spring 2.0 provided XML namespaces and AspectJ support; Spring 2.5 embraced annotation-driven configuration; Spring 3.0 introduced a strong Java 5+ foundation across the framework codebase, and features such as the Java-based @Configuration model.

Version 4.0 is the latest major release of the Spring Framework and the first to fully support Java 8 features. You can still use Spring with older versions of Java, however, the minimum requirement has now been raised to Java SE 6. We have also taken the opportunity of a major release to remove many deprecated classes and methods.

On Dec 2009 – Spring 3.0 released. In this time, there is lot of changes in the spring community. Spring is not just seen as the framework, it is moving beyond that level and seen as a enterprise solution provider. Spring is largest Java community in the world. After the acquisition by VMWare, Vmware and EMC has joined and started a initiative called Pivotal. Spring is integrated with the Pivotal team and providing all the Java solutions needed for the Pivotal customers. By looking at the new projects and road map of Spring, it is exciting to see them in the future.

Spring Modules

Spring framework consists of more than 20 modules grouped together. These are largely categorized as Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, and Test. These are very well depicted in the below diagram.

Spring Framework 4.0 Announced-

After nearly four years the popular Spring Framework is getting an upgrade from version 3 to version 4. Spring Framework co-founder and project lead Juergen Hoeller announced on his blog that the first milestone has been cut, although no early-access download link was provided.

The theme of version 4.0 seems to be Java SE 8 (based on OpenJDK 8 build 88+) and Java EE 7 support, plus some new usability features.

Spring Framework 4.0, a brand new major version of Spring that keeps Spring at the cutting edge of modern Java development. Together with the rest of the upcoming Spring IO Platform, Spring Framework 4.0 is positioned to empower the next decade of JVM based innovation, responding to, and setting trends in Developer Productivity, Big Data, Cloud, REST, and Micro Service Architecture.

Spring Framework 4.0 works beautifully with Java 8 and also allows applications to be written partially or entirely in Groovy, a concise dynamic language on the JVM. Spring Framework 4.0 also provides the foundation for new advances in the Spring IO platform such as Spring Boot. Spring Boot nearly eliminates initial configuration work altogether. Developer productivity options like these are typically associated with single-purpose frameworks that are limited in scope and simply do not offer the breadth, depth, and years of battle-tested production usage that Spring offers.

Spring 4 Features-

1. Spring Framework 4.0:

It provides support for several Java 8 features. You can make use of lambda expressions and method references with Spring’s callback interfaces.

2. Conditional Annotation in Spring 4 :

Conditional Annotation Indicates that a component is only eligible for registration when all specified conditions match. The primary objective is to create the bean only after the set of conditions are met.

3. RestController in Spring 4 :

One of the API improvements is new @RestController annotation which is inherited from the @Controller annotation. Prior to the version 4.0, all the Spring MVC components has to use the common @Controller annotation to mark that as the controller servlet.

4. General Web Improvements:

Deployment to Servlet 2.5 servers remains an option, but Spring Framework 4.0 is now focused primarily on Servlet 3.0+ environments. If you are using the Spring MVC Test Framework you will need to ensure that a Servlet 3.0 compatible JAR is in your test classpath.

Contents for Spring 4.0 Framework

  1. New Features and Enhancements in Spring Framework 4.0
  2. Environment Setup for Spring Framework 4.0
  3. Hello World Example using Spring Framework 4.0 API 
  4. RestController in Spring Framework 4.0
  5. Conditional Annotation in Spring 4.0  
  6. @ControllerAdvice improvements in Spring 4

References-
https://spring.io/blog/2013/12/12/announcing-spring-framework-4-0-ga-release

Next
Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

2 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

2 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

2 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

2 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

2 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

2 years ago