Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Architecture of Spring Framework: Modularity and Spring Modules

DZone 's Guide to

Architecture of Spring Framework: Modularity and Spring Modules

Learn more about modularity in the Spring Framework.

· Java Zone ·
Free Resource

One of the most important features of the Spring Framework is modularity — it is not one big monolith framework. Let's take a closer look at the architecture of the Spring Framework, Spring modules, and how they are organized.

Spring Architecture and Modules

Let’s look at the modules that are present in a typical Spring project. image info

It is not organized as one big JAR file. It is composed of a large number of smaller JAR files.

Spring is organized into modules. Here is how Spring is organized conceptually: image info

Container

This is the most heavily used part of the Spring Framework. This includes modules such as:

  • Beans: to manage application dependencies
  • Core
  • Context: to maintain the application context

Database Access and Integration

Spring provides excellent options for implementing data and integration layers.

The important data access modules are:

  • JDBC: to talk to relational database using JDBC
  • ORM: provides integration with all ORM (Object Relational Mapping) frameworks, such as Hibernate and MyBatis.
  • JMS: If you want to talk to another application over a queue, JMS provides an excellent option. Spring has good integration with JMS.
  • OXM: This module provides good integration in scenarios where object to XML mappings are required.
  • Transactions: Transaction management is an important part of data access integration functionality. Ideally, you want the transaction to be fully successful, or completely rolled back. If a transaction has four steps and failed at the third step, the previous two successful steps must also be rolled back. Spring has great support for transaction management.

Web

Additionally, Spring offers support for developing your web layer:

  • Spring MVC: It is Spring’s own web framework
  • Struts: Spring also provides great integration with Struts.

Cross-Cutting Features

An application is typically developed in multiple layers. For example, a web application is often designed to have three layers: web, business, and data:

image info

There are many things that are applicable to more than one layer. Those are called cross-cutting concerns.

Unit Testing

One important cross-cutting concern is unit testing. We want to be able to unit test code in all the three layers mentioned above. The Spring Test Framework provides great support for unit testing.

AOP

AOP stands for aspect-oriented rogramming. This module is useful for implementing features such as security and logging, and Spring AOP provides basic AOP features.

Spring can be integrated with the AspectJ framework to conduct advanced AOP. For more, check out the video below:

image info


In this article, we had a brief look at the modular structure of the Spring Framework. It is not a single monolith but is organized as a set of small modules.

Join our free Spring Boot in 10 Steps course.

Topics:
java ,spring ,spring framework ,modules ,modularity ,spring modules

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}