JavaRush /Java Blog /Random EN /What you need to know about Spring: history, key modules,...

What you need to know about Spring: history, key modules, comparison with Java EE

Published in the Random EN group
Hello! At the moment, the most popular development direction for a developer with knowledge of Java is web development. Of course, for this specialty there is a list of technologies required to study. One of the main ones is Spring . You might argue that you can learn Java EEWhat you need to know about Spring: history, key modules, comparison with Java EE - 1 instead . This is, of course, true, but now the vast majority of new projects use Spring , which has made it virtually the default, mandatory technology for a Java web developer. And if you want to keep up with the needs of the market, you will have to study it. Today I would like to talk about Spring , namely, to expand your vision of it a little: talk about the history of its creation, key differences from the Java EE stack and give a short overview of the key components of the Spring stack. Let's get started! What you need to know about Spring: history, key modules, comparison with Java EE - 2

1. How and when Spring appeared and what it evolved into over time

It all started in October 2002 , when Rod Johnson wrote the book “Expert One-onOne J2EE Design and Development”: What you need to know about Spring: history, key modules, comparison with Java EE - 3In this book, published by Wrox , the author describes the state of enterprise Java development at that time and points out a number of shortcomings of Java EE and component-based EJB (Enterprise Java Bean) environments . At the same time, Rod Johnson proposes a simpler solution based on regular Java classes (POJO - plain old Java objects) and dependency injection. In the book, he explains how you can create a high-quality, scalable online reservation application without using EJB. Those. he clearly demonstrated how to remove the complexity of application development and make it possible to use simple JavaBeans to achieve everything that was previously only possible using EJBs. However, the scope of Spring is not limited to the development of software components running on the server side. Any Java application can take advantage of the framework's advantages in terms of simplicity, testability, and loose coupling. His J2EE development design became an instant hit. Much of the application code, provided freely as part of the book, was reusable, and a number of developers soon began using it in their projects. Wrox had a web page for the book with the source code and patches. They also provided an online forum for the book. In February 2003, developers Jürgen Heller and Jann Karoff convinced Rod Johnson to create an open source project based on the framework's code. From that moment on, Rod, Jurgen and Yann began their collaboration to create something completely new. In fact, it was Yann Karoff who came up with the name “Spring” for the new framework. What was meant here is that Spring is like spring: a new start after the “winter” of traditional J2EE.
  • In June 2003, Spring 0.9 was released under the Apache 2.0 license.
  • Spring 1.0 was released in March 2004. Interestingly, even before the release of Spring 1.0, the previous version 0.9 was very well received and was widely adopted.
  • In August 2004, Rod Johnson, Jürgen Heller, Keith Donald and Colin Sampaleanu co-founded interface21 , a Spring consulting, training and support company.
  • October 2006: Spring 2.0 is released, which simplifies XML configuration files.
  • Spring 2.5, released in November 2007, introduced annotation configurations.
  • Spring 3.2, released in December 2012, introduced Java configuration, supported Java 7, Hibernate 4, Servlet 3.0, and also required at least Java 1.5.
  • Yann Karoff left the team early on. Rod Johnson left the spring team in 2012. Jürgen Heller is still an active member of the Spring development team.
  • Spring 4.0, released in 2014, added support for Java 8.
  • Also in 2014, Spring Boot was introduced to the world.
  • Spring 5.0 was released in 2017. Like Spring Boot 2.x, which supports Spring 5.
  • Actually, this is how our favorite framework became what we know it now.

2. Spring vs Java EE

Let's make a small comparison of two key Java stacks for web developers: Spring and Java EE. What you need to know about Spring: history, key modules, comparison with Java EE - 4
Java EE
Advantages Flaws
  • Applications written in Java EE are considered more reliable, secure and scalable
  • Java EE is an industry-approved API standard
  • Mainly based on annotations and CDI (context and dependency injection), just like Spring
  • Implementation based on EJB containers and POJOs
  • Complex applications with large number of transactions are handled very well by JEE
  • Successful in use for a scalable monolithic application
  • Java EE has its own OOP language containing a specific style and syntax
  • A very complex application development environment that is difficult for beginners to understand (and sometimes for old people too)
  • The final cost of the project, including design, deployment and application development, may be prohibitive
Java EE, licensed by Oracle, is designed for organizations and companies that require a broadly adaptable, distributable environment for building mass-market applications. Like Spring, Java EE includes additional libraries for database access (JDBC, JPA), remote engineering invocation (RMI), information (JMS), web administration, XML processing and characterizes standard APIs for enterprise JavaBeans, portlets, Servlets, Java Server Pages, etc. What you need to know about Spring: history, key modules, comparison with Java EE - 5The fundamental goal of Java EE is to unravel the major issues faced by developers regarding building current applications using various APIs. At the same time, development in Java EE has a high level of complexity, which raises the bar prohibitively high not only for beginners. And it can be difficult for experienced specialists to understand already written functionality, so development in Java EE takes longer and, accordingly, is more expensive. About Java EE in a nutshell we can say this: Complex, but flexible. Well, now let's talk a little about Spring . What you need to know about Spring: history, key modules, comparison with Java EE - 6
Spring
Advantages Flaws
  • Allows you to effectively organize object interactions
  • More simple than Java EE
  • Implemented on the basis of IOC and AOP , which ensures loose coupling of applications
  • Works based on XML, Groovy or annotation configuration
  • Allows you to use plain old Java objects - POJOs, developers don't need an enterprise container like an application server
  • Provides Java developers with a high level of modularity
  • Provides implementations of Java EE libraries, but in its own way, making their use much easier
  • Open Source License
  • Spring Boot greatly simplifies the initial application setup
  • Spring application code is generally easy to test
  • Spring is relatively difficult to develop because it lacks a clear focus
  • For a new Java developer, learning the Spring framework can be challenging (but still easier than Java EE)
  • Spring is slower than Java EE
Spring is an open source Java framework for large businesses. The Spring framework aims to provide the simplest possible implementation of J2EE ideas and leverage excellent programming practices by extending the capabilities of the POJO-based programming model. Those. Java EE is more of an official standard, while Spring is more of a framework that implements this standard in its own way.

Comparison results

In my understanding, Java EE and Spring are like JDBC and Hibernate, where JDBC is a faster technology, but at the same time with a lot of unnecessary code. And Hibernate already uses JDBC, but at the same time simplifying and reducing development significantly (albeit imposing some restrictions). It is impossible to say for sure which of them is better. This is also somewhat reminiscent of the question: which is better - ArrayList or LinkedList. After all, the answer will be the same - depending on the situation. Each of them has its own strengths and weaknesses, and you need to choose from them carefully, weighing your situation and understanding which of them will bring the most benefit now. What you need to know about Spring: history, key modules, comparison with Java EE - 7

3. Spring Components

Well, now let's talk a little about the frameworks that make up Spring.

Spring framework

It is the core module that provides a comprehensive programming and configuration model for modern Java-based enterprise applications—on any deployment platform. It contains many of the core (core) Spring technologies :
  • core - basic functionality that implements the concepts of IoC (inversion of control) and DI (dependency injection) ;
  • AOP - Aspect-Oriented Programming - aspect-oriented programming aimed at implementing end-to-end logic;
  • MVC and WebFlux - frameworks for web interaction;
  • JDBC , ORM - technologies for interacting with databases;
  • Test - functionality for transparent, uncomplicated testing of Spring container data;
  • SpEL - Spring Expression Language - Spring expression language;
  • etc.

Spring Boot

Simplifies the creation of Spring -based applications by minimizing the initial application setup and auto-configuring Spring application elements. Example of starting Spring boot in 5 minutes

Spring Data

Significantly simplifies the use of data access technologies, relational and non-relational databases (removes repetitive code and simplifies interaction with data). This article contains a good tutorial on connecting Spring Data.

Spring Cloud

It is used in microservice architecture, simplifying the interaction of microservices with each other and automating the deployment of applications on cloud platforms such as AWS , Azure , etc. See a detailed tutorial on Spring Cloud here , but I will warn you that this topic is not an easy one and is aimed at specialists close to the senior level.

Spring Security

Provides a powerful and customizable authentication (authentication) and access control (authorization) tool for an application. You can find a simple example of connecting Spring Security to your application in this post . What you need to know about Spring: history, key modules, comparison with Java EE - 8

Spring GraphQL

This module provides support for Spring applications built on GraphQL Java. GraphQL is a query language for APIs that allows clients to query a limited set of data they need, which in turn allows data to be collected in a limited number of queries. If you are already familiar with JPA, you may have already come across EntityGraph, with a similar (or the same) concept. You can read more about GraphQL here .

Spring Session

This part of the Spring framework provides APIs and implementations for managing user session information (user session data is stored in persistent storage like Redis , MongoDb , HazelCast , etc.). An example of using Spring Session can be found here .

Spring Integration

This module is designed to simplify messaging in Spring-based applications and support integration with external systems through declarative adapters. These adapters provide a higher level of abstraction than Spring's support for remoting, messaging, and scheduling. Detailed article .

Spring REST

Provides a rich set of tools that simplify REST API development: tools for routing requests, for converting JSON/XML into objects of the required types, etc. An example of a RESTful service in Spring can be found in this material .

Spring Web Flow

Spring Web Flow is based on Spring MVC and allows you to implement "flows" of a web application. Such flows encapsulate a sequence of steps that guide a user through the completion of some business task. They span multiple HTTP requests, are stateful, work with transactional data, are reusable, and can be dynamic and durable in nature. An example of connecting Spring Web Flow can be seen in this guide in English .

Spring WebServices

This module is designed to make it easier to develop contract-based SOAP services by allowing you to create flexible web services using one of many ways to manipulate XML payloads. SOAP - Simple Object Access Protocol - Simple object access protocol.

Spring HATEOAS

The module provides some APIs to make it easier to create REST controllers that follow the HATEOAS principle when working with Spring and especially Spring MVC. HATEOAS - Hypermedia As The Engine Of Application State - Hypermedia as the engine of application state. You can see the use of this Spring library here .

Spring Batch

This module provides functionality for batch data processing (when data is processed in large pieces - batches), vital for the daily operation of corporate systems. Spring Batch provides reusable features that are needed to handle large volumes of records, including logging/tracing, transaction management, job processing statistics, job restarting, skipping, and resource management. You can find an interesting review on Spring Batch at this link .

Spring AMQP

The module applies core Spring concepts to the development of AMQP-based messaging solutions. It provides a template as a high-level abstraction for sending and receiving messages. It also provides support for message-driven POJOs with a listener container. AMQP - Advanced Message Queuing Protocol - Advanced Message Queuing Protocol. The project contains two parts: spring-amqp is the base abstraction, and spring-rabbit is the implementation for RabbitMQ . Example with RabbitMQ connection using Spring What you need to know about Spring: history, key modules, comparison with Java EE - 9

Spring for Apache Kafka

This project applies core Spring concepts to the development of Kafka- based messaging solutions . A template is provided as a high-level abstraction for sending messages. It also provides support for message-driven POJOs with the necessary annotations and a listener container. There is a clear similarity here with Spring AMQP, but this module is adapted specifically for Kafka. An example of connecting Spring Kafka can be seen here .

Spring CredHub

Provides client-side support for storing, retrieving, and deleting credentials from a CredHub server running on the Cloud Foundry platform . CredHub - Provides an API for securely storing, creating, retrieving, and deleting various types of credentials. Spring CredHub provides a Java binding for the CredHub API, making it easy to integrate Spring applications with CredHub.

Spring FLO

It is a JavaScript library that offers a simple HTML5 embeddable visual designer for pipelines and simple graphs for monitoring streaming and batch data. A demo of this technology is in the video at the link .

Spring LDAP

This library simplifies LDAP operations and is based on the Spring JdbcTemplate. The framework allows searching and closing context, viewing results, encoding/decoding values, filters and much more (built on the same principles as Spring Jdbc) An example implementation of Spring LDAP can be found here .

Spring Roo

This module provides a RAD tool that can create and manage your Spring-based application. Its goal is to improve the productivity of Java developers. It can't write your application's business logic, but it can handle configuration and infrastructure stuff.

Spring Shell

The library makes it easy to create a full-featured shell (also known as command line) application by relying on Spring Shell jars and adding your own commands (which come as methods in Spring beans). Creating a command line application can be useful, for example, to interact with your project's REST API or to work with local file content. Read more here and here .

Spring Statemachine

This module allows application developers to use state machine concepts with Spring applications. A detailed example of using this functionality can be found here and here .

Spring Vault

Spring Vault provides familiar Spring abstractions and client-side support for accessing, storing, and revoking secrets. It offers both low-level and high-level abstractions for interacting with Vault , freeing the user from infrastructure concerns. Example of Spring Vault implementation What you need to know about Spring: history, key modules, comparison with Java EE - 10“Do I need to learn all this?” - you ask in amazement. Don't be scared! This is wrong! More precisely, not quite like that. This was the complete list of available technologies in Spring. The list of technologies that a beginner needs to know is much more modest:
  • Spring Core
  • Spring Boot
  • Spring Web (MVC and REST)
  • Spring Data (Spring ORM, Spring JDBC, Spring JPA)
  • Spring Test
There are also other technologies that are often found on projects, but due to their complexity, they are usually dealt with by more experienced developers rather than green novices. However, it is also useful for beginners to at least have a general understanding of:
  • Spring Security
  • Spring AOP
  • Spring Cloud
Other technologies are used much less frequently, so you only need to study them seriously to work on a specific project. By the way, you can find a complete checklist of what a Java developer should know in my other article. That's all for me today, see you all soon! What you need to know about Spring: history, key modules, comparison with Java EE - 11
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION