// Tutorial //

Spring Tutorial - Spring Core Framework Tutorials

Published on August 3, 2022
Default avatar
By Pankaj
Developer and author at DigitalOcean.
Spring Tutorial - Spring Core Framework Tutorials

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Spring is one of the most widely used Java EE frameworks. I have written a lot on Spring Tutorial and this is a summary post that will work as an index to go through with all of them in order.

Spring Tutorial

All of the spring tutorials come with example projects that you can download from the tutorial pages.

Spring Core Tutorials

Spring Framework is based on two design principles - Dependency Injection and Aspect Oriented Programming. Please go through the below tutorials to learn about the core spring concepts with implementation examples.

  1. Spring Framework A brief look at the evolution of the Spring Framework, its architecture, core components, and principles that guides the development of this amazing framework.
  2. Dependency Injection Java Example This post provides the basics of Dependency Injection and how we can implement DI pattern in simple java applications. It’s a good point to start with and then move to Spring Dependency Injection.
  3. Spring Dependency Injection This tutorial is aimed to provide dependency injection example in Spring framework with both annotation based configuration and XML based configuration. The tutorial also include JUnit test program to validate the implementation.
  4. Spring AOP Example This tutorial explains core concepts of Aspect-Oriented Programming such as Aspect, Advice, Pointcut, Joinpoint, AOP Proxy and Weaving. The tutorial explains about different types of Advice with simple program.
  5. Spring AOP Method Profiling
  6. Spring IoC Container and Spring Bean Example Tutorial This tutorial is aimed to explain the core concepts of Spring IoC container and Spring Bean with example programs. The tutorial explains about IoC Container and it’s core classes and different ways to create ApplicationContext. The tutorial also explains about Spring Bean, Spring Bean scopes, different ways to configure spring bean - XML, annotation, java-based through an example project.
  7. Spring Bean Scopes Spring Bean Scopes allows us to have more granular control of the bean instances creation.
  8. Spring Bean Autowiring Example Spring IoC container is smart to figure out the bean for injecting dependencies through “spring autowire” attribute. This tutorial explains about different types of auto wiring with an example project.
  9. Spring Bean Life Cycle Spring Beans are the most important part of any Spring application. Spring ApplicationContext is responsible to initialize the Spring Beans defined in spring bean configuration file. This tutorial explains about different ways through which we can provide post-initialization and pre-destroy methods in a spring bean - InitializingBean/DisposableBean interfaces or init-method/destroy-method attributes. Spring framework also support @PostConstruct and @PreDestroy annotations for defining post-init and pre-destroy methods. These annotations are part of javax.annotation package. You will also learn about Spring Aware interfaces that you can use to inject Servlet API objects into the spring bean.
  10. Spring 5 Spring 5 was released in late 2017. Spring 5 brings a massive update to the Spring framework.
  11. Spring WebFlux Spring WebFlux is the new module introduced in Spring 5. Spring WebFlux is the first step towards the reactive programming model in spring framework.
  12. Spring Data JPA Spring Data JPA is part of the Spring Data family. Spring Data makes it easier to create Spring driven applications that use new ways to access data, such as non-relational databases, map-reduction frameworks, cloud services, as well as well-advanced relational database support.

Spring Annotations

  1. Spring Annotations A brief look at the most important annotations in spring framework.
  2. Spring @Bean Spring @Bean Annotation is applied on a method to specify that it returns a bean to be managed by Spring context. Spring Bean annotation is usually declared in Configuration classes methods.
  3. Spring @Service Spring @Service annotation is a specialization of @Component annotation. Spring Service annotation can be applied only to classes. It is used to mark the class as a service provider.
  4. Spring @Component Spring Component annotation is used to denote a class as Component. It means that the Spring framework will autodetect these classes for dependency injection when annotation-based configuration and classpath scanning is used.
  5. Spring @RestController Spring RestController annotation is a convenience annotation that is itself annotated with @Controller and @ResponseBody. This annotation is applied to a class to mark it as a request handler.
  6. Spring @Controller Spring Controller annotation is a specialization of @Component annotation. Spring Controller annotation is typically used in combination with annotated handler methods based on the RequestMapping annotation.
  7. Spring @Repository Spring @Repository annotation is used to indicate that the class provides the mechanism for storage, retrieval, search, update and delete operation on objects.
  8. Spring @Configuration Spring @Configuration annotation is part of the spring core framework. Spring Configuration annotation indicates that the class has @Bean definition methods. So Spring container can process the class and generate Spring Beans to be used in the application.
  9. Spring @Value Spring @Value annotation is used to assign default values to variables and method arguments. We can read spring environment variables as well as system variables using @Value annotation.
  10. Spring @PropertySource Spring @PropertySource annotation is used to provide properties file to Spring Environment. This annotation is used with @Configuration classes.
  11. Spring @PostConstruct and @PreDestroy When we annotate a method in Spring Bean with @PostConstruct annotation, it gets executed after the spring bean is initialized. When we annotate a Spring Bean method with PreDestroy annotation, it gets called when bean instance is getting removed from the context.
  12. Spring @Async Spring @Async annotation allows us to create asynchronous methods in spring. Let’s explore @Async in this tutorial on spring framework.

Spring Boot Tutorials

  1. Spring Boot Tutorial
  2. Spring Boot Components
  3. Spring Boot @SpringBootApplication, SpringApplication Class Spring Boot @SpringBootApplication annotation is used to mark a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning. Spring Boot SpringApplication class is used to bootstrap and launch a Spring application from a Java main method.
  4. Spring Boot REST This tutorial explains how to create REST web services using the Spring Boot module.
  5. Spring Boot MongoDB Learn how to use MongoDB in a Spring Boot application.
  6. Spring Boot Redis Cache This article explains how to integrate Redis Cache into a spring boot application.
  7. Spring Boot Elasticsearch This article explains how to integrate Elasticsearch with a spring boot application.
  8. Spring Boot Actuator Endpoints Spring Boot Actuator Endpoints lets us monitor and interact with our application. Spring Actuator is a Spring Boot sub-module and provides built-in endpoints that we can enable and disable for our application.
  9. Spring Boot Initializr Web Interface
  10. Spring Boot CLI Example
  11. Spring Boot – Cannot determine embedded database driver class for database type NONE
  12. Spring Boot Interview Questions

Spring MVC Tutorial

  1. Spring MVC Tutorial for Beginners with Spring Tool Suite Spring MVC modules help us in creating java based web applications. This is the first post in the spring MVC series and you will learn how to use Spring Tool Suite (STS) and create a simple Web application using Spring MVC framework.
  2. Spring MVC Example This tutorial explains how to create a Spring MVC application using maven and Eclipse IDE, without using the Spring Tool Suite.
  3. Spring Restful Web Service Example with JSON Spring Framework provides built-in support for Jackson JSON API and we can utilize it to create a restful web service that will return JSON response. This tutorial explains all the different parts of the application that are required to configure our application to return JSON response and implement Rest API.
  4. Spring REST XML and JSON Spring REST supports both XML and JSON based request-response messages. This tutorial explains how easily we can support both of them using simple configurations.
  5. Spring RestTemplate Spring RestTemplate provides a convenient way to test RESTful web services. We can use RestTemplate to test HTTP based restful web services, it doesn’t support the HTTPS protocol.
  6. Spring MVC File Upload Example File uploading is one of the common tasks of a web application, that’s why Spring provides built-in support for file uploading by integrating Apache Commons FileUpload API. This tutorial is aimed to provide an understanding of how different components are configured with an example of upload single and multiple files.
  7. Spring MVC Internationalization and Localization Example Any web application with users all around the world, internationalization (i18n) or localization (L10n) is very important for better user interaction. Most of the web application frameworks provide easy ways to localize the application based on user locale settings. Spring also follows the pattern and provides extensive support for internationalization (i18n) through the use of Spring interceptors, Locale Resolvers and Resource Bundles for different locales. This tutorial explains the i18n and l10n process in a spring web application through an example project.
  8. Spring MVC Form Validation Example When we accept user inputs in any web application, it becomes necessary to validate them. We can validate the user input at the client-side using JavaScript but it’s also necessary to validate them at server side to make sure we are processing valid data in case the user has javascript disabled. Spring MVC Framework supports JSR-303 specs by default and all we need is to add JSR-303 and it’s implementation dependencies in Spring MVC application. Spring also provides @Validator annotation and BindingResult class through which we can get the errors raised by Validator implementation in the controller request handler method. The tutorial provides a form validation example using annotations and also explains the process to create our own custom validator.
  9. Spring MVC Exception Handling Any web application requires a good design for exception handling because we don’t want to serve container generated page when any unhandled exception is thrown by our application. Spring MVC Framework provides an approach for robust exception handling in Controller classes, Global Exception Handler and through HandlerExceptionResolver implementation. Check out the example project in the tutorial to learn more about spring MVC exception handling.
  10. Spring MVC Interceptors Example Sometimes we want to intercept the HTTP Request and do some processing before handing it over to the controller handler methods. That’s where Spring MVC Interceptors come handy. We can create our own interceptors in Spring by either implementing org.springframework.web.servlet.HandlerInterceptor interface or by overriding abstract class org.springframework.web.servlet.handler.HandlerInterceptorAdapter that provides the base implementation of this interface. Check out the example project in the tutorial to learn more about Spring MVC interceptors.
  11. Spring MVC RequestMapping Example @RequestMapping is one of the most widely used Spring MVC annotation. org.springframework.web.bind.annotation.RequestMapping annotation is used to map web requests onto specific handler classes and/or handler methods. @RequestMapping can be applied to the controller class as well as methods. This tutorial explains about different usage with examples and test program.
  12. Spring Session Management Spring Session Module provides APIs and implementation for managing user session in a web application. Spring Session decouples session management logic from the application, making it more fault-tolerant. Spring Session consists of the following modules: Spring Session Core, Spring Session JDBC, Spring Session Data Redis, and Spring Session Hazelcast.
  13. Spring MVC Gradle Example

Spring Batch Tutorials

  1. Spring Batch Spring Batch allows us to easily process a large number of records by creating batches. This article explains what is spring batch, its architecture and when to use spring batch application.
  2. Spring Batch Example This tutorial explains how to create spring batch project to process large CSV files.

Spring JDBC Tutorial

Most of the enterprise application deals with relational databases. That’s why Spring provides extensive support for JDBC API and it also provides wrappers to perform Database CRUD operations.

  1. Spring JDBC and JdbcTemplate CRUD with DataSource Example Spring Framework provides excellent integration with JDBC API and provides JdbcTemplate utility class that we can use to avoid boiler-plate code from our database operations logic such as Opening/Closing Connection, ResultSet, PreparedStatement, etc. This tutorial provides an example of CRUD operations using Spring JDBC integration.
  2. Spring DataSource JNDI with Tomcat Example We also know that DataSource with JNDI is the preferred way to achieve connection pooling and get benefits of container implementations. This tutorial explains how we can use DataSource defined in tomcat container as a JNDI resource to get database connection and perform different operations. This is the preferred way for getting database connections in a spring web application because the container takes care of managing database resources.
  3. Spring Transaction Management Example with JDBC Transaction Management is a trivial task in any enterprise application. Spring provides extensive support for transaction management and helps developers to focus more on business logic rather than worrying about data integrity. Spring declarative transaction management is the preferred approach for transaction management because it’s very easy to use and there is no direct dependency, it uses AOP and Dependency injection.
  4. Spring JdbcTemplate Spring JdbcTemplate class is the core of Spring JDBC module. It provides various methods to execute SQL queries, read result set data, etc.

Spring Hibernate Tutorial

Spring is one of the most widely used Java EE frameworks and Hibernate is the best ORM framework in the market. That’s why Spring provides built-in support for Hibernate in Spring ORM module.

  1. Spring Hibernate Integration Example This tutorial provides complete details with an example to integrate hibernate with Spring standalone application. The example shows the integration between Spring 4 + Hibernate 4 as well as Spring 4 + Hibernate 3.
  2. Spring MVC Hibernate CRUD Example Spring MVC can be easily integrated with Hibernate framework. Also, we can utilize Spring Declarative transaction management, that makes our application free with boiler-plate code.
  3. Spring ORM Example
  4. Spring ORM with AOP Transaction Management

Spring Security Tutorial

Spring Security can be applied to any Java web application, it works as a separate part of the application and provides different ways for authentication and authorization.

  1. Spring Security in Servlet Web Application This tutorial explains the basics of the spring security module. It also provides an example for in-memory, DAO, and JDBC based authentication with an example project.
  2. Spring MVC Security Example If we are using the Spring MVC framework, applying spring security very easy because we already have spring-based configurations. All we need is to plug in the security-related configurations.
  3. Spring 4 Security This article explains about the Spring Security module introduced in Spring 4.
  4. Spring Security MVC This article explains how to use spring security into a Spring MVC application.
  5. Spring Security Role Based Access Authorization

Spring Integration Tutorials

  1. Spring JSF Integration Example Tutorial JSF is a component-based framework with great emphasis on user interfaces whereas Spring core principle is dependency injection. This tutorial explains how to get the best out of these by integration JSF with Spring Framework.
  2. Primefaces Spring & Hibernate Integration Example Tutorial This is one of the integration examples where we have explained how to integrate PrimeFaces with Spring and Hibernate framework. This is a very commonly used combination to get the most out of each of the frameworks.
  3. PrimeFaces Hibernate SpringRoo Integration Example SpringRoo is an open-source software tool that uses the convention-over-configuration concept to facilitate producing Java-Based enterprise software application in a driven command-line way. This tutorial explains about integration between SpringRoo, PrimeFaces and Hibernate frameworks.

Spring Messaging

  1. Spring AMQP
  2. Spring RabbitMQ
  3. Spring RabbitMQ Example
  4. Spring ActiveMQ Part 1
  5. Spring ActiveMQ Part 2

Spring Interview Questions

If you are going for Java EE interview where Spring is a requirement, I hope this post will help you in refreshing your knowledge in quick time. That’s all for Spring tutorials for now. Spring Framework has a lot of modules and I will be posting about them in the future and keep including them here. So I would suggest you bookmark this post for future references.


Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up
About the authors
Default avatar
Pankaj

author

Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?

Java is really in mature language. Even the latest Java Spring is all hose sh*t. All other systems already provided all that IOC, AOP already 30 years ago. And when do we need to use and provide polymorphism,

- 2much2learn

    Where is the article for Spring Data JPA ?

    - Deepak

      This post is not just informative but impressive also. This is really a good source of information, I will follow it to know more information and expand my knowledge, I think everyone should know it.

      - jack jons

        Great work , I also want tutorial for Microservices . Thank you .

        - Raj Gopal

          I want to learn 1) Java project case studies 2) Low Level Design and High Level Design 3) Java Project Designing. Please help me if any courses available to learn. Thanks for understanding

          - Muralidhar V

            your tutorials are excellent. Can you guide me through carrying out CRUD on image data with MVC pattern or Spring? I will appreciate a detail example.

            - Alabi Razaq

              Always great to read from here. Nice explanation

              - Paddy

                Needed to compose you a very little word to thank you yet again regarding the nice suggestions, you’ve contributed here. Appreciating the persistence you put into your blog and detailed the information you provide.

                - Bhuvi.S

                  Thanks for this post

                  - Amol

                    Spring is a lightweight framework. It is otherwise called master of framework because it supports to other frameworks Struts, EJB, Hibernate and so on.This tutorial really helps you to understand the spring framework in easy way. Thanks a lot for sharing this article!

                    - pranit