Spring Boot Fundamentals

Introduction to Spring Boot

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

This segment introduces Spring Boot as part of the Spring Framework.

Keywords

  • spring boot
  • auto-configuration

About this video

Author(s)
Felipe Gutierrez
First online
22 May 2021
DOI
https://doi.org/10.1007/978-1-4842-7066-0_5
Online ISBN
978-1-4842-7066-0
Publisher
Apress
Copyright information
© Felipe Gutierrez 2021

Video Transcript

Hello and welcome back. Let’s review Spring Boot. A Spring Boot makes it easy to create stand-alone and production-grade Spring based applications with ease. We can say that the Spring Boot is an opinionated runtime and help you to create applications fast. It also has easy to use features. Let’s review some of these features.

First of all, it has a sensible defaults meaning that the common configuration that you can find in any Spring project is going to be covered by the Spring Boot, and we’re going to see that very soon. Thanks to the sensible defaults we have the auto configuration, meaning that is going to review the classpath that you have as dependencies for your project, and based on that is going to create all the necessary configuration for that project. Normally, it will be just by adding these simple starters that is going to help the Spring Boot to understand what you try to do.

For example, if you include a web dependency, a web starter, automatically it’s going to configure everything related to a web application. And we’re going to see that when we start getting to the internals. Of course, it’s going to provide a production ready features like metrics and health checks with Spring Boot Actuator. Also, it has the ability to create a stand-alone, and runnable, and deployable apps with just a simple command. And of course, there is no code generation and zero configuration in most of the cases. And we’re going to see that as well. The Spring Boot has also the support for any other configurations meaning that you can override the sensible defaults either using XML, Java Config, Annotations, Application Properties– either app.properties or the yaml files. Also, it supports a lot of range of projects, like for example, Web, Batch, JDBC, Integration, and so much more.

You want to see now Spring Boot the kind of a Spring way, you can see that. You can see that still will require some of the classes. Now, the configuration you can add the application properties or the yaml. You’re going to have that Spring context and then your amazing app. And if you want to simplify and we want to put just one line, what is a Spring Boot? We can say this. It’s just a Spring framework plus the auto configuration that is going to give you the power of the Spring Boot.

Now let’s take a look into our contacts app that we did in the previous segment now with Spring Boot. Let’s take a look into their requirements. First, we are going to have Java 8 installed. Now we’re going to have any IDE– whatever you want to import that– take a look that we don’t require maybe any other kind of a requirement, right. So it’s going to be easier, it’s good to get simplified now. And of course, the specs aren’t going to change a little bit because now we’re going to display the current context in JSON format, and we’re going to still use the in-memory database for persistence– in this case, the H2 engine.

So let’s get started with the steps. First, we’re going to have opened the Spring Initializr. This is an application that the Spring team created for you to create projects very easy. Normally we’re going to add these dependency. Take a look, we’re going to do Web, Spring Data JPA, H2, and Lombok. And we’re going to talk about Lombok in a little bit. Step two, we’re going to create the context, the context controllers, and the context repository interface. Of course, we’re going to add the logic to do the persistent, the data, and expose the context as JSON format. And the last step is just run your app. It’s very, very simple. Take a look that now we don’t have several steps or we are pulling a lot of configuration and we’re going to see that with the Spring Boot context app demo. So let’s go.