Spring 4 Tutorial

This page is regularly updated with the latest information about the Spring 4 framework. It is the most recent stable release for the production applications. Please bookmark this page to have up-to-date information on Spring Framework 4.0 happenings. 

Spring 3 released on 2009. After a long time, a major release Spring 4 is from Spring community. 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.

A comprehensive coverage on Spring is updated at Spring Tutorial.

The purpose of this tutorial is to organize all the posts published on Spring 4 and the recent releases after the main release of Spring 4. It is a one stop location where you can find everything about the spring 4. This page will be updated with the latest new and announcement about the Spring 4 framework.

Spring 4 Tutorials and Examples

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 Architecture

( Image Source )

Spring 4 Releases

Latest : The current version is Spring 4.2. The next planned release is Spring 4.3.0 which is scheduled to be released on March 2016.

  • New Features in Spring 4.0 (Preview) : Early announcement for the new version on spring framework. It highlights the expected new features to be introduced.
  • Spring 4.1 Release Announced : New features added are omprehensive web resource handling, Caching support revisited, JMS support overhaul and Performance improvements.
  • Spring 4.2 Released : This is another feature release with minor features and enhancements added to the existing features. Some of the notable features are Integration with Hibernate ORM 5.0, Annotation Based application events, bean scripting, @JsonView on STOMP endpoint methods and many other features.

Spring 4 Features

  • Spring 4.0 Environment Setup : This tutorials explains the list of dependencies and configurations required for running the Spring 4 applications.
  • 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.
  • 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.
  • Spring 4 – Generics Type as Qualifier : One of the improvements introduces in Spring 4 is the generic types as a form of qualifier when injecting Beans. We have several types of methods to determine the closely matching types for the @Autowired annotation. With the Spring 4 release, you can inject the beans using the narrowing of generic types.

  • @ControllerAdvice : With the release of Spring 4.0, one of the feature is improvements over the existing @ControllerAdvice annotation. You can narrow the scope of the exception handler. For example, you can declare a exception handler which will handle only the exception thrown by the @RestController , a special type of controller introduced in the Spring 4.0.
  • @Profile Annotation : This tutorial explain how to enable profiles in your spring application for different environments. Also this tutorial explains the new improvements in the Spring 4.0 release and how it is different from the older releases.
  • Removed Deprecated Packages and Methods : There are lot of deprecated classes and methods from the previous release 3.2.4 has been completely removed in the Spring 4 release. You can find the list of APIs that has been either removed, added and changed in the Spring 3.2.4 to Spring 4.0.0 API differences report.
  • Java 8 Support : On March 27, 2014, the Spring community was happy to announce the Spring Framework 4.0.3. The reason why is that it was the first release of the Spring Framework with Java 8 support. You can read some of the Java 8 features are used in the Spring API. One more thing is that Java 6 become the minimum requirement to run the Spring 4 applications.

Spring 4.2 Features

  • Better Application Events : Application events are available since the very beginning of the Spring framework as a mean for loosely coupled components to exchange information. One of the most well known usage of application events is the following

Spring MVC

  • Spring 4 REST Example : This tutorial provides a simple example for writing the Spring MVC REST services using the Spring 4 APIs. We have written several articles about the spring 4 features in our previous articles. The REST implementation on Spriing 4 also very much similiar to the previous releases. Here I have provided the sample source code what I have used to implement the REST services.

Other Topics

Spring 4 Adoption : There is a nice survey published by Baeldund on Spring 4 Adoption. It is clearly shows that most of the projects are already migrated to the latest release of the Spring framework.

Spring 4 Survey

( Source )

Spring Articles Collection Links


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>