00 - What is Spring Boot?

springboot
web
Features of this framework

Introduction

From spring.io:

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”.

Features:

  • Create stand-alone Spring applications
  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
  • Provide opinionated ‘starter’ dependencies to simplify your build configuration
  • Automatically configure Spring and 3rd party libraries whenever possible
  • Provide production-ready features such as metrics, health checks, and externalized configuration
  • Absolutely no code generation and no requirements for XML configuration

IBM has an article about why Spring Framework is so popular and how Spring Boot eases the creation of Spring projects: From ibm.com:

Spring Framework offers a dependency injection feature that lets objects define their own dependencies that the Spring container later injects into them. This enables developers to create modular applications consisting of loosely coupled components that are ideal for microservices and distributed network applications.

As capable as comprehensive as Spring Framework is, it still requires significant time and knowledge to configure, set up, and deploy Spring applications. Spring Boot mitigates this effort with three important capabilities.

Capabilities:

Autoconfiguration:

Autoconfiguration means that applications are initialized with pre-set dependencies that you don’t have to configure manually.

  • As Java Spring Boot comes with built-in autoconfiguration capabilities, it automatically configures both the underlying Spring Framework and third-party packages based on your settings (and based on best practices, which helps avoid errors)
  • Even though you can override these defaults once the initialization is complete, Java Spring Boot’s autoconfiguration feature enables you to start developing your Spring-based applications fast and reduces the possibility of human errors.

Opinionated approach

Spring Boot uses an opinionated approach to adding and configuring starter dependencies, based on the needs of your project.

  • Following its own judgement, Spring Boot chooses which packages to install and which default values to use, rather than requiring you to make all those decisions yourself and set up everything manually.
  • You can define the needs of your projects during the initialization process, during which you choose among multiple starter dependencies –called _Spring Starters– that cover typical use cases. You run Spring Boot Initializr by filling out a simple web form, without any codingYou can define the needs of

Standalone applications

Spring Boot helps developers create applications that just run.

  • It lets you create standalone applications that run on their own, without relying on an external web server, by embedding a web server such as Tomcat or Netty into your app during the initialization process
  • As a result, you can launch your application on any platform by simply hitting th Run command

Fundamentals

Some of the key concepts of Spring Boot and how it works include:

  • Beans: a Java object managed by the Spring container
    • Beans are typically defined in configuration files, and the Spring container is responsible for instantiating, configuring, and managing the lifecycle of these beans
  • Dependency Injection: Spring uses dependency injection to manage the dependencies between beans
    • This means that instead of instantiating and configureing dependencies manually, you can use annotations or configuration files to tell the Spring container which dependencies a bean has and how they should be instantiated
  • Object-Oriented Programming: it uses interfaces and inheritance to create a modular and reusable codebase
  • Aspect-Oriented Programming: this allows to separate cross-cutting concerns such as logging, security, and transaction management from the core business logic of your application
  • Data Access: Spring Boot provides a set of starters and libraries for connecting to databases and performing data access operations.
    • It also provides support for Object-Relational-Mapping (ORM) frameworks such as Hibernate and JPA
  • Web Development: Spring Boot provides a set of starters and libraries for building web applications and RESTful web services.
    • It also provides support for web technoligies such as Spring MVC and Thymeleaf
  • Annotations: Spring Boot uses annotations extensively to configure beans and manage dependencies
    • Understanding the different annotations available in Spring, such as @Bean, @Autowired, @Component, can help you effectively use the framework
  • MVC (Model-View-Controller): Spring Boot provides support for the MVC architectural pattern, which separates the application into three layers:
    • The model (data)
    • The view (presentation)
    • The controller (logic)
    Understanding how MVC works in Spring boot can help you structure your appliication effectively. See model entry for more details regarding MVC.
  • REST (Representational State Transfer): Spring Boot provides support for building RESTful web services.
    • Understanding the principles of REST and how to create RESTful web services using Spring Boot can help you effectively use the framework
To sum up

Overall, Spring Boot works by providing a set of pre-configured options and defaults, as well as a set of tools for quickly creating and running an application using the Spring Framework.

It uses concepts such as beans, dependency injection and OOP to make it easy to build and run a Spring-based application, with minimal configuration and setup required.