Spring: Big Picture

What is Spring?

Spring makes it easy to create Java enterprise applications.It is a complimentary to Java EE. Spring is open source. It has a large and active community. Spring 5.0 requires JDK 8+ and provides out-of-the-box support for JDK 9.

Fundation: Spring Framework

The Spring Framework is an application framework and inversion of control container for the Java platform. There are 6 key areas: Core, Web, AOP, Data Access, Integration, Test.

spring overview
Spring Framework

Spring Core

Spring Core is Dependency injection container. It creates and maintains objects and their dependencies.

What is Dependecy Injection?

Dependency injection is a pattern that implements IoC. We create has-a relationship in traditional programming by creating and instance of aclass in another class. Dependency Injection in Spring can be done through constructors, setters or fields. The Spring documentation recommends using constructor-based injection for mandatory dependencies, and setter-based injection for optional ones.


In the case of constructor-based dependency injection, the container will invoke a constructor with arguments each representing a dependency we want to set.


For setter-based dependency injection, the container will call setter method sof our class, after invoking a no-argument constructor or no-argument staticfactory method to instantiate the bean.


In case of Field-Based dependency injection, we can inject the dependencies by markingthem with an @Autowired annotation:

public class Store {
    private Item item; 

Spring Web

Spring Web is a framework for handling web requests. It can be handled via Web MVC or WebFlux.

Spring Web MVC

It uses Java Servlet behind the scenes. Advantage of Spring MVC is high lever API to interact with. It is easier than  usage more productivity.

Spring WebFlux

Spring’s Reactive web programing framework.

  • Web requests are executed asynchronously
  • They don’t wait

Spring AOP

Increases the organization of code by allowing the seperation of cross-cutting concerns.

Prevents duplicated code accross the application

Classifc example is Security

Spring Data Access

It makes easier to develop applications that interact with data

Database transactions are much easier than JDBC 

It provides Exception Translation. For more info: https://www.baeldung.com/spring-dataIntegrityviolationexception

Spring Integration

Spring makes it easy to expose and utilize web services.

Exposing web services

public class StudentController {

    public Student getAccount(@PathVariable int id) {
        return findStudentById(id);

Utilize web services with RestTemplate

RestTemplate hides details and handles

  • Opening connection
  • Sending command
  • Handling response
package hello;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.client.RestTemplate;

public class Application {

    private static final Logger log = LoggerFactory.getLogger(Application.class);

    public static void main(String args[]) {
        RestTemplate restTemplate = new RestTemplate();
        Quote quote = restTemplate.getForObject("http://foo.com/student/1", Student.class);


Spring Boot

Spring Boot is build on top of Spring framework. The notable features are 


Setting up Auto-configuration is easy (e.g.: @EnableAutoConfiguration)


Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. The typical process for running Java Web Application is packaging application, choosing and configuring webserver, deploying the application to the web server, and starting the web application server. 


Most Spring Boot applications need very little Spring configuration. https://start.spring.io/ is a great example for opinionated view of the Spring platform and third-party libraries

Other Spring Projects

Spring Data

It makes it easy to use data access technologies, relational and non-relational databases, map-reduce frameworks, and cloud-based data services. This is an umbrella project which contains many subprojects that are specific to a given database. The projects are developed by working together with many of the companies and developers that are behind these exciting technologies.

Spring Cloud

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. microservices). Spring Cloud takes a very declarative approach, and often you get a lot of fetaures with just a classpath change and/or an annotation. Example application that is a discovery client:

public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);

Spring Security Project

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

Is it good fit for you?


Well engineered
Stood the test of time. It is not a “yet another framework”
Huge community
Widely used in industry
Very actively developed


Increases the size of the deliverable
Hard to debug
Adds memory overhead

Leave a Reply

Your email address will not be published. Required fields are marked *