Partner – Microsoft – NPI (cat= Spring)
announcement - icon

Azure Spring Apps is a fully managed service from Microsoft (built in collaboration with VMware), focused on building and deploying Spring Boot applications on Azure Cloud without worrying about Kubernetes.

And, the Enterprise plan comes with some interesting features, such as commercial Spring runtime support, a 99.95% SLA and some deep discounts (up to 47%) when you are ready for production.

>> Learn more and deploy your first Spring Boot app to Azure.

You can also ask questions and leave feedback on the Azure Spring Apps GitHub page.

1. Introduction

The Spring Framework provides a clean and expressive programming and configuration model for modern Java-based enterprise applications that can run on any deployment platform.

This article covers the high-level overview of the Spring framework and mainly, the org.springframework package which provides support for dependency injection, transaction management, web applications, data access, messaging, testing and more.

2. Features

Spring framework offers a comprehensive list of features:

  • Spring MVC web application and RESTful web service framework
  • Aspect-Oriented Programming including Spring’s declarative transaction management
  • Dependency Injection
  • Inversion of Control

and much more.

3. Maven Dependencies

If you want to add Spring to your Maven project, you can find more information about it here.

4. Spring Projects

The Framework includes a number of different modules and projects. From configuration to security, web apps to big data – whatever the infrastructure needs of your application may be, there is a Spring Project to help you build it.

Start small and use just what you need – Spring is modular by design. Let’s look at some of those projects here.

4.1. Spring Web MVC

Web MVC framework provides Model-View-Controller architecture, designed around a DispatcherServlet which handles all the HTTP requests and responses and makes the application loosely coupled.

The best thing about it is it allows you to use any object as a command or form object – there is no need to implement a framework-specific interface or base class. Its data binding is highly flexible: for example, it treats type mismatches as validation errors that can be evaluated by the application, not as system errors.

Here you can find the complete guide.

4.2. Spring IO Platform

IO Platform defines a set of dependencies (both Spring Framework dependencies as third-party libraries) that could be included on a Java project to allow you to choose the necessary dependencies without worrying about compatibility between their versions (because Spring IO guarantees it).

The IO Platform is certified to work with Java 7 and 8.

Have a look at the GitHub project.

4.3. Spring Boot

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. It makes it very easy to create a Spring-powered application with a minimum of work.

An application created with it can be largely autoconfigured with some sensible defaults and next to that can be improved with metrics (how many requests, how long did requests take etc.).

It consists of several (optional) modules:

  1. CLI – A command line interface, based on Groovy, to start/stop spring boot created applications.
  2. Boot Core – The base for other modules.
  3. Auto-configure – Module to auto-configure a wide range of Spring projects. It will detect an availability of certain frameworks (Spring Batch, Spring Data JPA, Hibernate, JDBC).
  4. Actuator – This project, when added, will enable certain enterprise features (Security, Metrics, Default Error pages) to your application.
  5. Starters – Different quickstart projects to include as a dependency in your Maven or Gradle build file. It will have the needed dependencies for that type of application. Currently, there are starter projects for a web project (tomcat and jetty based), Spring Batch, Spring Data JPA, Spring Integration, Spring Security exist.
  6. Tools – The Maven and Gradle build tool as well as the custom Spring Boot Loader (used in the single executable jar/war) is included in this project.

We can find the Maven artifact here and have a look at the GitHub project.

4.4. Spring Data

Spring Data’s mission is to provide a familiar and consistent, Spring-based programming model for data access while still retaining the special traits of the underlying data store.

The primary goal of this project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services as well as provide improved support for relational database technologies.

This is an umbrella project which contains many sub-projects that are specific to a given database (like JPA, MongoDB, Redis, Apache Solr, Gemfire, Apache Cassandra). The projects are developed by working together with many of the companies and developers that are behind these exciting technologies.

4.5. Spring Security

Spring Security is a framework that focuses on providing both authentication and authorization to Java applications. Like all Spring projects, the real power of Spring Security is found in how easily it can be extended to meet custom requirements. It is released under an Apache 2.0 license so you can confidently use it in your projects.

It is also easy to learn, deploy and manage. It has dedicated security namespace which provides directives for most common operations, allowing complete application security in just a few lines of XML and can protect your apps against attacks like session fixation, clickjacking, cross-site request forgery, etc.

Spring Security is also integrated with many other Spring technologies, including Spring Web Flow, Spring Web Services and Pivotal tc Server.

Do have a look at the FAQs of Spring security to have a deeper insight and the Maven dependency page. Also, have a look at Spring security tutorials for Authentication, Registration, and setup Spring Security with Maven.

4.6. Spring Social

Spring Social is an extension of the framework that enables applications to connect with Software-as-a-Service providers such as Twitter, Facebook, and other OAuth authentication based APIs. It provides a ready to use OAuth authentication framework for web based applications.

Features:

  • An extensible service provider framework that greatly simplifies the process of connecting local user accounts to hosted provider accounts.
  • A connect controller that handles the authorization flow between your Java/Spring web application, a service provider, and your users.
  • Java bindings to popular service provider APIs such as Facebook, Twitter, LinkedIn, TripIt, and GitHub.
  • A sign-in controller that enables users to authenticate with your application by signing in through a service provider.

Getting Started Guides:

Spring provides quite a few examples of GitHub projects to make you start quickly and Spring Social reference is handy as well with a quick start page.

4.7. Spring Shell

Spring Shell is an interactive shell that can be easily extended with commands using a Spring based programming model.

Users of the shell project can easily build a full featured shell (aka command line) application by depending on the Spring Shell jar and adding their own commands (which come as methods on spring beans). Creating a command line application can be useful e.g. to interact with your project’s REST API, or to work with local file content.

The GitHub project can be found here.

4.8. Spring Mobile

Spring Mobile is an extension of the framework and Spring Web MVC that aims to simplify the development of mobile web applications.

Spring Mobile is a framework that provides capabilities to detect the type of device making a request to your Spring website and serve alternative views based on that device. Like all Spring projects, the real power of Spring Mobile is found in how easily it can be extended.
Features:

  • A Device resolver abstraction for server-side detection of mobile and tablet devices
  • Site preference management that allows the user to indicate if he or she prefers a “normal”, “mobile”, or “tablet” experience
  • A site switcher capable of switching the user to the most appropriate site, either mobile, tablet or normal, based on his or her device and optionally indicated a site preference
  • Device aware view management for organizing and managing different views for specific devices.

This sample application will get you started quickly.

You can also detect a device, handle a website preference or serve mobile web content with Spring MVC.

4.9. Spring Batch

Spring Batch is a lightweight, comprehensive framework aimed at enabling the development of batch applications vital for the daily operations of enterprise systems.

Batch applications in this context refer to automated offline systems targeted towards bulk data processing. Spring Batch automates this basic batch iteration, providing the capability to process similar transactions as a set, typically in an offline environment without any user interaction.

Spring Batch works by reading data with a configurable chunk size from a data source, process it and finally write it to a resource.

The data source for the reader can be flat files (text file, XML file, CSV file…), relational database (MySQL…), MongoDB.
Similarly, a writer can write data to flat files, relational databases, MongoDB, mailer etc.

Get started quickly by Creating a Batch Service and with other Spring batch resources.

5. Core Spring Packages

Here, let’s take a look at core Spring packages.

  • org.springframework.cache – This package supports sub packages and classes for declarative cache management, setting up the open source cache in Caffeine library, support classes for the open source cache EhCache 2.x.

  • org.springframework.context – This package builds on the beans package to add support for message sources and for the Observer design pattern, and the ability for application objects to obtain resources using a consistent API.

  • org.springframework.core – Provides basic classes for exception handling and version detection and other core helpers that are not specific to any part of the framework.

  • org.springframework.expression – This package provides core abstractions behind the Spring Expression Language.

  • org.springframework.http – This package contains a basic abstraction over client/server-side HTTP.

  • org.springframework.jdbc – The classes in this package make JDBC easier to use and reduce the likelihood of common errors.
  • org.springframework.jms – This package contains integration classes for JMS, allowing for Spring-style JMS access.

  • org.springframework.jndi – The classes in this package make JNDI easier to use, facilitating the accessing of configuration stored in JNDI, and provide useful superclasses for JNDI access classes.

  • org.springframework.orm.hibernate5 – Package providing integration of Hibernate 5.x with Spring concepts.

  • org.springframework.test.util – General utility classes for use in unit and integration tests.

This list is limited and just describes core packages for Spring framework. You can find the complete listing here.

6. Conclusion

In this quick overview article, we had a look at various projects which are present in Spring ecosystem and made a rich collection of Maven dependencies, the GitHub projects, and the comprehensive features each project offers to make our web apps secure, scalable and easy to live with.

We also had a look at core packages which provide us power to focus on a logical aspect of our apps.

Course – LS (cat=Spring)

Get started with Spring and Spring Boot, through the Learn Spring course:

>> THE COURSE
res – REST with Spring (eBook) (everywhere)
Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.