The Wayback Machine - https://web.archive.org/web/20241001081334/https://www.geeksforgeeks.org/spring-framework-architecture/
Open In App

Spring Framework Architecture

Last Updated : 19 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The Spring framework is a widely-used open-source Java framework that provides a comprehensive programming and configuration model for building enterprise applications. Its architecture is designed around two core principles: Dependency Injection (DI) and Aspect-Oriented Programming (AOP).

The Spring framework consists of several modules, which can be categorized into four main areas: Core Container, Data Access/Integration, Web, and Miscellaneous. The Core Container provides the fundamental functionality of the Spring framework, including the IoC container and ApplicationContext. The Data Access/Integration area provides support for integrating with databases and other data sources. The Web area provides support for building web applications, including the Spring MVC and Spring WebFlux modules. The Miscellaneous area includes other modules that provide additional functionality, such as the Spring Security module for authentication and authorization features.

  • Dependency Injection (DI) is a design pattern that helps to reduce the coupling between the components of an application. By using DI, the Spring framework enables loose coupling between components, making the application more modular and easier to maintain. The Spring framework provides an Inversion of Control (IoC) container, which is responsible for creating and managing instances of JavaBeans, and the ApplicationContext, which provides a unified view of the entire application configuration.
  • Aspect-Oriented Programming (AOP) allows developers to modularize cross-cutting concerns, such as logging, security, and transaction management, and apply them to multiple components of an application. This results in a more modular and reusable codebase. The Spring framework provides an AOP framework, which is responsible for managing cross-cutting concerns in the application, such as logging, security, and transaction management.
  • Overall, the Spring framework architecture is based on the principles of modularity, separation of concerns, and flexibility, providing developers with a powerful set of tools to build robust, scalable, and maintainable enterprise applications. The framework’s modular architecture allows developers to select only the necessary modules for their specific needs, reducing unnecessary overhead and complexity in the application. Additionally, the Spring framework’s flexible configuration model allows developers to configure the application using various approaches, such as XML-based configuration, Java-based configuration, and annotation-based configuration.

Spring Modules

Spring Modules

Spring Modules

The Spring framework is modular and consists of several modules that provide different functionalities to help build enterprise applications. The modules can be broadly categorized into four main areas: Core Container, Data Access/Integration, Web, and Miscellaneous. Let’s take a closer look at each area and its corresponding modules:

Core Container

  • The Core Container provides the fundamental functionality of the Spring framework, including the Inversion of Control (IoC) container and the ApplicationContext. It includes the following modules:
    • Spring Core: This module provides the fundamental functionality of the Spring framework, including IoC and DI. The IoC container is the heart of the Spring Framework, responsible for creating and managing instances of JavaBeans. It uses dependency injection to wire the beans together.
    • Spring Beans: This module provides the BeanFactory, which is the basic building block of the IoC container, and the BeanWrapper, which is responsible for managing the lifecycle of a bean. The Bean Factory is the core interface for accessing the IoC container. It provides methods for retrieving beans.
    • Spring Context: This module provides the ApplicationContext, which is an advanced version of the BeanFactory and provides additional features, such as internationalization and resource loading, and the ability to publish and consume events.
    • Spring Expression Language (SpEL): This module provides a powerful expression language for querying and manipulating objects during runtime. SpEL supports a wide range of features, including property access, method invocation, conditionals, loops, and type conversion. It also provides support for accessing variables and functions defined in the application context, as well as support for defining custom functions and variables.

Data Access/Integration

  • The Data Access/Integration area provides support for integrating with databases and other data sources. It includes the following modules:
    • Spring JDBC: This module provides a simple JDBC abstraction layer that reduces the amount of boilerplate code required to work with JDBC. Spring JDBC provides support for transaction management, allowing developers to manage database transactions declaratively using Spring’s transaction management.
    • Spring ORM: This module provides integration with Object-Relational Mapping (ORM) frameworks, such as Hibernate and JPA. Spring ORM provides a higher-level abstraction layer on top of ORM frameworks, allowing developers to write less boilerplate code and more easily integrate ORM technologies with other Spring features, such as transaction management and caching.
    • Spring Data: This module provides a consistent and easy-to-use programming model for working with data access technologies, including databases, NoSQL, and cloud-based data services. Spring Data provides a wide range of features, including automatic CRUD (Create, Read, Update, Delete) operations, query generation from method names, support for pagination and sorting, integration with Spring’s transaction management, and more. Additionally, Spring Data provides support for common data access patterns, such as repositories and data access objects (DAOs).
    • Spring Transaction: This module provides support for declarative transaction management in Spring applications. Spring Transaction provides support for various transaction propagation and isolation levels, allowing developers to manage transactions at different levels of granularity. Additionally, Spring Transaction provides support for different transaction management strategies, such as using a JTA transaction manager or a simple JDBC transaction manager.

Web

  • The Web area provides support for building web applications. It includes the following modules:
    • Spring MVC: This module provides a Model-View-Controller (MVC) framework for building web applications. Spring MVC provides a range of features, including support for handling HTTP requests and responses, form handling, data binding, validation, and more. It also provides support for different view technologies, such as JSP (JavaServer Pages), Thymeleaf, and Velocity, allowing developers to choose the view technology that best suits their needs.
    • Spring WebFlux: This module provides a reactive programming model for building web applications that require high concurrency and scalability. Spring WebFlux provides support for building reactive web applications using a range of technologies, such as Netty, Undertow, and Servlet 3.1+ containers. It also provides a range of features, including support for reactive data access, reactive stream processing, and reactive HTTP clients.
    • Spring Web Services: This module provides support for building SOAP-based and RESTful web services. Spring Web Services provides support for generating WSDL (Web Services Description Language) from Java classes, and for generating Java classes from WSDL. This allows developers to define the contract (i.e., the interface) of their web service using WSDL, and to generate the Java classes that implement the web service from the WSDL.

Miscellaneous

  • The Miscellaneous area includes other modules that provide additional functionality, such as:
    • Spring Security: This module provides authentication and authorization features for Spring applications. Spring Security provides a range of authorization mechanisms, such as role-based access control and expression-based access control. It also provides support for securing different parts of the application using different security configurations, allowing developers to apply fine-grained security policies.
    • Spring Integration: This module provides support for building message-driven and event-driven architectures. Spring Integration provides a range of integration patterns, such as messaging, routing, and transformation. It provides support for a range of messaging systems, such as JMS, AMQP, and Apache Kafka. It also provides support for integrating with different protocols, such as FTP, HTTP, and TCP.
    • Spring Batch: This module provides support for batch processing and integration with enterprise systems. Spring Batch provides a range of tools and utilities for building and managing batch processing applications, such as support for testing and debugging batch jobs, logging and monitoring, and integration with other Spring modules, such as Spring Data and Spring Integration.
    • Spring Cloud: This module provides support for building cloud-native applications using Spring technologies. Spring Cloud provides a range of features for building cloud-native applications, such as service discovery, configuration management, and load balancing. It provides support for integrating with different cloud platforms, such as AWS and GCP, and for using different cloud-native technologies, such as containers and serverless computing.
  • Overall, the Spring framework modules provide developers with a powerful set of tools to build robust, scalable, and maintainable enterprise applications. The modular architecture of the Spring framework allows developers to select only the necessary modules for their specific needs, reducing unnecessary overhead and complexity in the application.

Conclusion

In conclusion, the Spring framework is a powerful and popular open-source Java framework that provides a comprehensive programming and configuration model for building enterprise applications. Its architecture is designed around the principles of modularity, separation of concerns, and flexibility, providing developers with a powerful set of tools to build robust, scalable, and maintainable enterprise applications.



Previous Article
Next Article

Similar Reads

Spring Boot - Reactive Programming Using Spring Webflux Framework
In this article, we will explore React programming in Spring Boot, Reactive programming is an asynchronous, non-blocking programming paradigm for developing highly responsive applications that react to external stimuli. What is Reactive ProgrammingIn reactive programming, the flow of data is asynchronous through push-based publishers and subscriber
4 min read
Spring Boot - Spring JDBC vs Spring Data JDBC
Spring JDBC Spring can perform JDBC operations by having connectivity with any one of jars of RDBMS like MySQL, Oracle, or SQL Server, etc., For example, if we are connecting with MySQL, then we need to connect "mysql-connector-java". Let us see how a pom.xml file of a maven project looks like. C/C++ Code <?xml version="1.0" encoding=
4 min read
Difference Between Spring DAO vs Spring ORM vs Spring JDBC
The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring-DAO Spring-DAO is not a spring module. It does not provide interfaces or templates
5 min read
Spring vs Spring Boot vs Spring MVC
Are you ready to dive into the exciting world of Java development? Whether you're a seasoned pro or just starting out, this article is your gateway to mastering the top frameworks and technologies in Java development. We'll explore the Spring framework, known for its versatility and lightweight nature, making it perfect for enterprise-level softwar
8 min read
Introduction to the Spring Data Framework
In the previous article, we have already discussed about spring framework and spring boot. In this article, we will understand about spring data framework. The need for Spring Data Framework Our digital world is holding more than 20 zettabytes of data, and that is around as many bits of information as the stars in our physical universe. These data
5 min read
Spring Framework Annotations
Spring framework is one of the most popular Java EE frameworks. It is an open-source lightweight framework that allows Java EE 7 developers to build simple, reliable, and scalable enterprise applications. This framework mainly focuses on providing various ways to help you manage your business objects. Now talking about Spring Annotation, Spring Ann
5 min read
Spring - ORM Framework
Spring-ORM is a technique or a Design Pattern used to access a relational database from an object-oriented language. ORM (Object Relation Mapping) covers many persistence technologies. They are as follows: JPA(Java Persistence API): It is mainly used to persist data between Java objects and relational databases. It acts as a bridge between object-o
2 min read
Top 10 Most Common Spring Framework Mistakes
"A person who never made a mistake never tried anything new" - Well said the thought of Albert Einstein. Human beings are prone to make mistakes. Be it technological aspect, mistakes are obvious. And when we talk about technology, frameworks play a very important role in building web applications. Frameworks have a defined set of codes that can be
6 min read
10 Reasons to Use Spring Framework in Projects
Spring is the season that is known for fresh leaves, new flowers, and joy which makes our minds more creative. Do you know there is a bonus for us? We have another Spring as well. Our very own Spring framework! It is an open-source application framework that is used for building Java applications and projects. There are many reasons for which Sprin
6 min read
Remoting in Spring Framework
Spring has integration classes for remoting support that use a variety of technologies. The Spring framework simplifies the development of remote-enabled services. It saves a significant amount of code by having its own API. The remote support simplifies the building of remote-enabled services, which are implemented by your standard (Spring) POJOs.
3 min read
What is Spring Framework and Hibernate ORM?
Spring Framework is an open-source Java framework that is used to develop enterprise-level applications. It provides a wide range of features and functionalities such as inversion of control (IoC), dependency injection (DI), aspect-oriented programming (AOP), and more. These features help developers to build robust, scalable, and maintainable appli
5 min read
Introduction to Spring Framework
Prior to the advent of Enterprise Java Beans (EJB), Java developers needed to use JavaBeans to create Web applications. Although JavaBeans helped in the development of user interface (UI) components, they were not able to provide services, such as transaction management and security, which were required for developing robust and secure enterprise a
10 min read
Spring - MVC Framework
Spring MVC Framework follows the Model-View-Controller architectural design pattern which works around the Front Controller i.e. the Dispatcher Servlet. The Dispatcher Servlet handles and dispatches all the incoming HTTP requests to the appropriate controller. It uses @Controller and @RequestMapping as default request handlers. The @Controller anno
4 min read
Spring Framework Standalone Collections
Spring Framework allows to inject of collection objects into a bean through constructor dependency injection or setter dependency injection using <list>,<map>,<set>, etc. Given below is an example of the same. Example Projectpom.xml:  [GFGTABS] XML <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="htt
2 min read
Spring Boot - Architecture
The Spring Boot is built on top of the core Spring framework. It is a simplified and automated version of the spring framework. The spring boot follows a layered architecture in which each layer communicates to other layers(Above or below in hierarchical order). The spring boot documentation provides the following definition to the Spring Boot Fram
2 min read
Spring Security Architecture
Spring Security framework adds two important capabilities to web applications, Authentication Authorization/Access Control This framework provides protection against popular security issues like SCRF attacks, or Fixation attacks. It provides a secure and standard way to set up user login functionality in web applications and thus provides quick use
2 min read
Java Spring Boot Microservices - Develop API Gateway Using Spring Cloud Gateway
The API Gateway Pattern in some cases stands for “Backend for frontend”. It is basically the entry gate for taking entry into any application by an external source. The pattern is going on in a programmer’s mind while they are making the client’s application. It acts as a medium between the client applications and microservices. For example-Netflix
4 min read
Spring Boot | How to access database using Spring Data JPA
Spring Data JPA is a method to implement JPA repositories to add the data access layer in applications easily. CRUD stands for create, retrieve, update, delete which are the possible operations which can be performed in a database. In this article, we will see an example of how to access data from a database(MySQL for this article) in a spring boot
4 min read
Difference between Spring MVC and Spring Boot
1. Spring MVC : Spring is widely used for creating scalable applications. For web applications Spring provides Spring MVC framework which is a widely used module of spring which is used to create scalable web applications. Spring MVC framework enables the separation of modules namely Model View, Controller, and seamlessly handles the application in
3 min read
How to Create a Spring Boot Project in Spring Initializr and Run it in IntelliJ IDEA?
Java language is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using Java is that it tries to connect every concept in the language to the real world with the help
3 min read
Spring - Add User Name and Password in Spring Security
Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications. 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 fou
3 min read
How to Create and Setup Spring Boot Project in Spring Tool Suite?
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework
3 min read
How to Run Your First Spring Boot Application in Spring Tool Suite?
Spring Tool Suite (STS) is a java IDE tailored for developing Spring-based enterprise applications. It is easier, faster, and more convenient. And most importantly it is based on Eclipse IDE. STS is free, open-source, and powered by VMware. Spring Tools 4 is the next generation of Spring tooling for the favorite coding environment. Largely rebuilt
3 min read
Spring - Add Roles in Spring Security
Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications. 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 fou
4 min read
Difference Between Spring Boot Starter Web and Spring Boot Starter Tomcat
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework
3 min read
Create and Run Your First Spring MVC Controller in Eclipse/Spring Tool Suite
Spring MVC framework enables separation of modules namely Model, View, and Controller, and seamlessly handles the application integration. This enables the developer to create complex applications also using plain java classes. The model object can be passed between view and controller using maps. In this article, we will see how to set up a Spring
5 min read
Spring - Using SQL Scripts with Spring JDBC + JPA + HSQLDB
We will be running the SQL scripts with Spring JDBC +JPA + HSQLDB. These scripts are used to perform SQL commands at the time of application start. Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. JPA is just a specification that faci
3 min read
How to Make a Project Using Spring Boot, MySQL, Spring Data JPA, and Maven?
For the sample project, below mentioned tools got used Java 8Eclipse IDE for developmentHibernate ORM, Spring framework with Spring Data JPAMySQL database, MySQL Connector Java as JDBC driver.Example Project Using Spring Boot, MySQL, Spring Data JPA, and Maven Project Structure: As this is getting prepared as a maven project, all dependencies are s
4 min read
How to Generate a New Spring Cloud Project in Spring Initializr?
Spring Initializr is a Web-based tool that generates the Spring Boot project structure. The spelling mistake in initializr is inspired by initializr. Modern IDEs have integrated Spring Initializr which provides the initial project structure. It is very easy for developers to select the necessary configuration for their projects. The Spring Initiali
2 min read
Spring - Integration of Spring 4, Struts 2, and Hibernate
In modern Java web application development, integrating different frameworks is a common requirement to leverage the strengths of each framework. Spring, Struts, and Hibernate are three popular frameworks that can work together seamlessly to build robust and scalable applications. In this article, we will explore how to integrate Spring 4, Struts 2
4 min read
Article Tags :
Practice Tags :