Spring Boot Overview

What Is Spring Boot?

  • It is a framework that lets you quickly use various libraries and frameworks provided by the Spring project.
  • It is something like the Spring version of Dropwizard.
  • When you build it, a single jar file is created.
    • For web applications, it starts the embedded Tomcat server. You can switch to Jetty or Undertow.
    • It can also run as a normal Java program rather than a web application.
  • It uses build tools such as Maven or Gradle. Ant is not supported.
  • If you add the components you want to use as dependencies, the settings required for integration are configured automatically.
  • You can write, build, and run Spring applications independently, and because embedded Tomcat or Jetty can be used, there is no need to package and deploy them as WAR files.
  • Because Tomcat or Jetty is embedded, the project can be deployed easily as a .jar file.
  • Complex XML settings are simplified and replaced with annotation-based Java config, making server configuration easier.
  • It allows you to build web projects quickly, similar to Django or Ruby on Rails.

Spring Boot Auto-configuration

  • @SpringBootApplication
    • Means that @Configuration, @EnableAutoConfiguration, and @ComponentScan are used together by default.
  • @Configuration
    • Declared on a class.
    • Provides one or more @Bean methods in the class and lets the Spring container create and manage those beans.
  • @EnableAutoConfiguration
    • Performs various default configuration tasks, such as embedded Tomcat server setup and automatic registration of Spring MVC’s DispatcherServlet.
  • @ComponentScan
    • Automatically scans classes annotated with @Component, @Service, @Repository, and @Controller, and registers them as beans.