Skip to content

Spring Boot Introduction#

Spring Boot is a framework from "The Spring Team" to ease the bootstrapping and development of new Spring applications. It provides default for code and annotation configuration to quick start new Spring projects within no time. It follows "Opinionated Defaults Configuration" approach to avoid lots of boilerplate code and configuration to improve development, UnitTest and intergration test process.

Springboot = SpringFramework + EmbeddedHttp servers (Tomcat, Jetty) - xml<bean>Configuration or @Configuration. 

The Problems#

  • As we know about Spring Framework in Spring Overview, building a traditional Spring application is really hard because we have to think many about controlling dependencies, setting up configurations (xml or Java) and deploying on WebServer like Tomcat, Jetty, ...etc.

Spring Boot Solution#

  • Java Spring Boot (Spring Boot) is a tool that makes developing web application and microservices with Spring Framework faster and easier through some core capabilities:
    • Minimize the amount of maunal configuration.
      • Perform auto-configuration based on property files and JAR classpath
    • Help to resolve dependency conflicts (Maven and Gradle)
    • Provide an embedded HTTP server so developers can start quickly.
      • Tomcat, Jetty, Undertow, ...

Spring Boot And Spring#

  • Spring Boot uses Spring behind the scenes.
  • Spring Boot simply makes it easier to use Spring.

Spring Initializr#

  • To create a Spring Boot project, we can use this website start.spring.io. In which we can:

    • Select our dependencies that we want to use.
    • Create a Maven or Gradle project.
    • Choose Java version
    • Choose Spring Boot version
  • Then after we generate the Spring Boot project, then we can import it into IDE like Eclipse, IntelliJ, NetBean etc... for using.

Spring Boot Embedded Server#

  • Spring Boot provide an embedded HTTP server so we can get start quickly. The embedded server can be Tomcat, Jetty, Undertow, ...etc.
  • So with the embedded server, we don't need to install a server separately. Our jar file will contain our application codes and embedded server.

 #zoom

Running Spring Boot App#

  • Spring Boot apps can be run standalone (includes embedded server).
  • We can start running the Spring Boot apps from IDE or command-line.
  • For example with the example Spring Boot jar file as below.

 #zoom

  • So we can use the command line below to start running the Spring Boot app.
java -jar sample-app.jar

Deploying Spring Boot App#

  • Spring Boot apps can also be deployed in the traditional way with war file.
  • We can deploy war file to an external server: Tomcat, JBoss, WebSphere etc...

 #zoom

Key Components Of SpringBoot Framework#

  • There are 4 major components

 #zoom

Summary#

  • 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 requirement for XML configuration.

See Also#

References#