Tutorial

Spring Boot Tutorial

Published on August 3, 2022
author

Rambabu Posa

Spring Boot Tutorial

Welcome to Spring Boot Tutorial. Spring Boot is a completely new project from Pivotal Team(The Spring Team). It is a Framework developed on top of existing Spring Framework.

Spring Boot Tutorial

Spring Boot uses completely new development model to make Java Development very easy by avoiding some tedious development steps and boilerplate code and configuration.

What is Spring Boot?

Spring Boot is a Framework from “The Spring Team” to ease the bootstrapping and development of new Spring Applications. It provides defaults for code and annotation configuration to quick start new Spring projects within no time. It follows “Opinionated Defaults Configuration” Approach to avoid lot of boilerplate code and configuration to improve Development, Unit Test and Integration Test Process.

What is NOT Spring Boot?

Spring Boot Framework is not implemented from the scratch by The Spring Team, rather than implemented on top of existing Spring Framework (Spring IO Platform). It is not used for solving any new problems. It is used to solve same problems like Spring Framework.

Why Spring Boot?

  • To ease the Java-based applications Development, Unit Test and Integration Test Process.
  • To reduce Development, Unit Test and Integration Test time by providing some defaults.
  • To increase Productivity.

Don’t worry about what is “Opinionated Defaults Configuration” Approach at this stage. We will explain this in detail with some examples in coming posts.

Advantages of Spring Boot:

  • It is very easy to develop Spring Based applications with Java or Groovy.
  • It reduces lots of development time and increases productivity.
  • It avoids writing lots of boilerplate Code, Annotations and XML Configuration.
  • It is very easy to integrate Spring Boot Application with its Spring Ecosystem like Spring JDBC, Spring ORM, Spring Data, Spring Security etc.
  • It follows “Opinionated Defaults Configuration” Approach to reduce Developer effort
  • It provides Embedded HTTP servers like Tomcat, Jetty etc. to develop and test our web applications very easily.
  • It provides CLI (Command Line Interface) tool to develop and test Spring Boot(Java or Groovy) Applications from command prompt very easily and quickly.
  • It provides lots of plugins to develop and test Spring Boot Applications very easily using Build Tools like Maven and Gradle
  • It provides lots of plugins to work with embedded and in-memory Databases very easily.

In Simple Terminology, What Spring Boot means What Is Spring Boot, Spring Boot Tutorial That means Spring Boot is nothing but existing Spring Framework + Some Embedded HTTP Servers (Tomcat/Jetty etc.) - XML or Annotations Configurations. Here minus means we don’t need to write any XML Configuration and few Annotations only.

Main Goal of Spring Boot:

The main goal of Spring Boot Framework is to reduce Development, Unit Test and Integration Test time and to ease the development of Production ready web applications very easily compared to existing Spring Framework, which really takes more time.

  • To avoid XML Configuration completely
  • To avoid defining more Annotation Configuration(It combined some existing Spring Framework Annotations to a simple and single Annotation)
  • To avoid writing lots of import statements
  • To provide some defaults to quick start new projects within no time.
  • To provide Opinionated Development approach.

By providing or avoiding these things, Spring Boot Framework reduces Development time, Developer Effort and increases productivity.

Limitation/Drawback of Spring Boot:

Spring Boot Framework has one limitation. It is some what bit time consuming process to convert existing or legacy Spring Framework projects into Spring Boot Applications but we can convert all kinds of projects into Spring Boot Applications. It is very easy to create brand new/Greenfield Projects using Spring Boot. To Start Opinionated Approach to create Spring Boot Applications, The Spring Team (The Pivotal Team) has provided the following three approaches.

  • Using Spring Boot CLI Tool
  • Using Spring STS IDE
  • Using Spring Initializr Website

We will discuss one by one in detail with some good examples in coming posts. We can find Spring Initializr Website at: https://start.spring.io/ We can develop two flavors of Spring-Based Applications using Spring Boot

  • Java-Based Applications
  • Groovy Applications

We can use Spring Boot CLI or Spring STS IDE or Spring Initializr Website to develop Spring Boot Groovy Applications. However, we can use Spring STS IDE or Spring Initializr Website to develop Spring Boot Java Applications. Anyhow, Groovy is also JVM language almost similar to Java Language. We can combine both Groovy and Java into one Project. Because like Java files, Groovy files are finally compiled into *.class files only. Both *.groovy and *.java files are converted to *.class file (Same byte code format). java groovy compiler, spring boot Spring Boot Framework Programming model is inspired by Groovy Programming model. Spring Boot internally uses some Groovy based techniques and tools to provide default imports and configuration. Spring Boot Framework also combined existing Spring Framework annotations into some simple or single annotations. We will explore those annotations one by one in coming posts with some real-time examples. Spring Boot Framework drastically changes Spring-Java Based Applications Programming model into new Programming model. As of now, Spring Boot is at initial stage only but future is all about Spring Boot only. Happy Spring Boot Framework Learning!

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Category:
Tutorial
Tags:

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
February 18, 2016

Nice Tutorial

- Mahesh

JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
February 2, 2017

hello every one i need small help, i want spring restful json object response code for excel file reading please help me out.

- Raju

JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
February 2, 2017

hello every one i need small help, i want spring restful json object response code for excel file reading please help me out. mail me on ngr.shakti@gmail.com

- Raju

    JournalDev
    DigitalOcean Employee
    DigitalOcean Employee badge
    March 8, 2016

    Nice introduction

    - Dev

      JournalDev
      DigitalOcean Employee
      DigitalOcean Employee badge
      March 24, 2016

      good introduction to know about Spring Boot.

      - Nilesh

        JournalDev
        DigitalOcean Employee
        DigitalOcean Employee badge
        March 30, 2016

        Nice introduction

        - Keshav Kumar

          JournalDev
          DigitalOcean Employee
          DigitalOcean Employee badge
          April 5, 2016

          Awesome tutorial. You could have kept “Next” button after each and every tutorial to learn the technology in a sequence manner. This helps us a lot… Thanks man :)

          - venkat

          JournalDev
          DigitalOcean Employee
          DigitalOcean Employee badge
          April 21, 2016

          how to go to next tutorial from the current one… any idea?

          - Rahul

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            May 31, 2016

            Awesome tutorial for introduction of spring boot and ease to understand Its helpful to us if you provide more tutorials

            - venkatesh

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            May 31, 2016

            Thanks, Find my full tutorials here. Let me know if you need anything more. Introduction to Spring Boot https://www.journaldev.com/7969/introduction-to-spring-boot Key Components and Internals of Spring Boot Framework https://www.journaldev.com/7989/key-components-and-internals-of-spring-boot-framework Spring Boot CLI Setup and HelloWorld Example https://www.journaldev.com/8195/spring-boot-cli-setup-and-helloworld-example Spring Boot Initilizr Web Interface https://www.journaldev.com/8225/spring-boot-initilizr-web-interface Spring Boot Initilizr With IDEs or IDE Plugins https://www.journaldev.com/8596/spring-boot-initilizr-with-ides-or-ide-plugins Spring Boot Initilizr With Spring Boot CLI https://www.journaldev.com/8609/spring-boot-initilizr-with-spring-boot-cli Spring Boot Initilizr With ThirdParty Tools https://www.journaldev.com/8650/spring-boot-initilizr-with-thirdparty-tools Spring Boot Framework In A Nutshell https://www.journaldev.com/8611/spring-boot-framework-ina-nutshell Thanks, Ram Rambabu Posa

            - Rambabu Posa

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            October 18, 2016

            Hi Rambabu, Can you please provide me one example, spring Boot with Restful webservices ? Regards, Subramanyam

            - Subramanyam

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            October 18, 2016

            Thanks for reading my tutorials. I’m preparing another series of posts on “Spring Microservices with Spring, Spring Boot, Spring Cloud etc”. It takes some more time to deliver all those posts. Please stay tune to my future Spring Boot posts. Ram

            - Rambabu Posa

              JournalDev
              DigitalOcean Employee
              DigitalOcean Employee badge
              July 19, 2016

              I like this tutorial, but you misspoke when you say it’s to reduce the time compared to Spring framework. The goal is to reduce time compared to ALL technologies (on the JVM, in the Ruby or Node.js or .NET landscapes, etc.). In this, we have succeeded. :)

              - Josh Long

              JournalDev
              DigitalOcean Employee
              DigitalOcean Employee badge
              July 20, 2016

              Josh, I totally agree. I have done .NET along side Java since, well, .NET came out. There is NOTHING like this in the .NET world. You can go to each .NET shop and they have their own “framework” just trying to do the basics of what Spring Framework does and each shop is using a different DI/IoC tool and ORM. Each app can dump half the code (and all their custom framework) by switching to Boot. Oh and get more (like metrics and health and …).

              - Mark

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                July 19, 2016

                I don’t agree that it takes a long time to convert to convert existing apps to Spring Boot. I have converted regular Spring 3.x apps (3 Spring applications) to Spring boot and it was just matter of 1-2 hours. These apps were fairly complex. one thing we followed throughout the lifecycle of pre-spring boot were to completely shun XML based configuration and that really reduced our conversion time. Moreover I have also converted few Play framework 2.4 based apps to Spring Boot and that was a little big undertaking ~3 days. But it was still worth in my opinion.

                - Sachin Walia

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                July 24, 2016

                I agree with the author. It would take weeks if not months to convert a real enterprise app to Spring Boot. You sir must be a guru

                - john

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                July 27, 2016

                Hi John, Thanks for reading my tutorials. I’m planning to deliver a tutorial on “How to develop Microservices using Spring Boot”. Will that make sense for you. Thanks, Ram

                - Rambabu Posa

                  JournalDev
                  DigitalOcean Employee
                  DigitalOcean Employee badge
                  August 2, 2016

                  Its good but if write own tutorials with real time example its beneficial for all but thanks to give overview about the new technology .

                  - Maqbul FIda Hussain

                    JournalDev
                    DigitalOcean Employee
                    DigitalOcean Employee badge
                    August 22, 2016

                    Hi i am looking for sample spring boot rest service with method interceptor implementation. I tried a lot…but no success.

                    - Venkatesh Dorai

                      JournalDev
                      DigitalOcean Employee
                      DigitalOcean Employee badge
                      September 18, 2016

                      Hi, My application using spring mvc, spring data jpa, mysql. I have a problem with data flow in my app… In the controller I am taking some model from DB, then I pass it to view - here some fields are shown (not all of them), and the user is able to modify them… Then when he submits form, the controller should update the model in db. The problem is flow, because not all of the fields are in tags, so they won’t pass after submiting the form… There are two solutions I found, One is to create additional tags with all of the fields, which are not used in to pass them forward… But in case I have many fields, for example - 30, I would have to create a lot of hidden fields… Second one is, Using @SessionAttributes & SessionStatus.isComplete(). In this way suppose user not called save action & navigates the another page in edit mode then Will the model stay in the session forever? Will it ever get cleaned out, or will the session keep growing larger and larger as the user navigates the site? What solution do you think would be the best? Code : @RequestMapping(value = “/edit/{id}”, method = RequestMethod.GET) public String editGuest(@PathVariable Long id, Model model) { model.addAttribute(“guest”, guestService.getById(id)); return “guest/new”; } @RequestMapping(value = “/”, method = RequestMethod.POST) public String saveGuest(@Valid Guest guest, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return “guest/new”; } Guest savedGuest = guestService.save(guest); return “redirect:/guests/show/” + savedGuest.getId(); }

                      - balaji

                        JournalDev
                        DigitalOcean Employee
                        DigitalOcean Employee badge
                        September 23, 2016

                        Really Nice article, thanks for that. Just have 1 question when it says: It avoids writing lots of boilerplate Code, Annotations and XML Configuration. What to do with Annotations here, as per my understand writing of Annotations are same in SpringBoot as Sprig framework. Please correct me.

                        - Pratik

                        JournalDev
                        DigitalOcean Employee
                        DigitalOcean Employee badge
                        October 28, 2016

                        Hi Good Question. If you see my next Sprint Boot tutorials you can find the answer. In Spring Boot, The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration and @ComponentScan Got it?? Ram

                        - Rambabu Posa

                          JournalDev
                          DigitalOcean Employee
                          DigitalOcean Employee badge
                          October 17, 2016

                          very good introduction about spring boot.

                          - Subramanyam

                            JournalDev
                            DigitalOcean Employee
                            DigitalOcean Employee badge
                            October 28, 2016

                            Hi Rambabu, I developed one application using spring boot when i am deployed in tomcat 6 it is not working,when it was deployed in tomcat 7 its working. Can you tell me is it any configuration required for deploying in Tomcat?? Regards Siva

                            - Siva

                            JournalDev
                            DigitalOcean Employee
                            DigitalOcean Employee badge
                            October 28, 2016

                            Hi Siva Spring Boot is developed on top of Servlet 3.x API. Tomcat 6.x supports only Servlet 2.5 and JSP 2.1 specifications. And Tomcat 7.x supports Servlet 3.0, JSP 2.2, EL 2.2 and Web Socket 1.1 specifications. That’s why your app is not working with Tomcat 6. Got it? any questions please? Ram

                            - Rambabu Posa

                            JournalDev
                            DigitalOcean Employee
                            DigitalOcean Employee badge
                            October 28, 2016

                            Hi Ram, yeah you said right but i want chnage servlet3.0 to servlet 2.5 because i want to test in tomcat 6.0. Can you please help me this. Thanks Siva

                            - Siva

                            JournalDev
                            DigitalOcean Employee
                            DigitalOcean Employee badge
                            November 24, 2016

                            In other words, you can’t use Spring Boot with tomcat 6.0, so if you want to test your application using servlet 2.5 specification you will need to change your approach instead of using spring boot. Regards!

                            - David Hertz

                              JournalDev
                              DigitalOcean Employee
                              DigitalOcean Employee badge
                              May 18, 2018

                              Thanks for contribution …

                              - Ravella Baji

                                JournalDev
                                DigitalOcean Employee
                                DigitalOcean Employee badge
                                October 29, 2016

                                Hi Rambabu, Its a nice introduction to springboot,I am developing a website to my department.my question is that,where i would place the html content(UI) like web content in those application.pls help Regards, Sai VIjay

                                - Sai Vijay

                                  JournalDev
                                  DigitalOcean Employee
                                  DigitalOcean Employee badge
                                  November 25, 2016

                                  hi … i have installed STS from eclipse market place…i am using Eclipse Luna. When i create a new project-> spring starter project It is giving me error that M2e connector is not installed. before Installing STS , maven was there, but after installing it just vanished frm my system… I hv even downloaded m2e connectors from market place… stl no success. please help

                                  - muff

                                  JournalDev
                                  DigitalOcean Employee
                                  DigitalOcean Employee badge
                                  November 25, 2016

                                  install maven separately.

                                  - Pankaj

                                  JournalDev
                                  DigitalOcean Employee
                                  DigitalOcean Employee badge
                                  November 28, 2016

                                  hi Pankaj… I have Installed maven also in eclipse , still i am getting the same error… Even i have downloaded the the apache maven 3.3 and set the MAven home in pathvariable,

                                  - muff

                                    JournalDev
                                    DigitalOcean Employee
                                    DigitalOcean Employee badge
                                    November 28, 2016

                                    Can you please provide me with your email id.

                                    - muff

                                      JournalDev
                                      DigitalOcean Employee
                                      DigitalOcean Employee badge
                                      December 5, 2016

                                      Very nice way to make clear concept for those who really wish to learn SpringBoot. i love this …

                                      - shangay lama

                                        JournalDev
                                        DigitalOcean Employee
                                        DigitalOcean Employee badge
                                        January 16, 2017

                                        very good introduction on spring boot to start with. Love to see more articles on this concept.

                                        - Srao

                                        JournalDev
                                        DigitalOcean Employee
                                        DigitalOcean Employee badge
                                        March 30, 2017

                                        nice article

                                        - parag

                                          JournalDev
                                          DigitalOcean Employee
                                          DigitalOcean Employee badge
                                          January 24, 2017

                                          Hi ,Did you done with Spring Microservices with spring boot ? am looking for it .

                                          - Abhijeet Deshmukh

                                          JournalDev
                                          DigitalOcean Employee
                                          DigitalOcean Employee badge
                                          January 26, 2017

                                          Hi Yes Im preparing Spring Boot Microservices examples and notes. You will get them soon. Ram

                                          - Rambabu Posa

                                          JournalDev
                                          DigitalOcean Employee
                                          DigitalOcean Employee badge
                                          February 1, 2017

                                          i also want spring boot microwaves notes examples. can you please tell when you will updated.

                                          - manisha

                                            JournalDev
                                            DigitalOcean Employee
                                            DigitalOcean Employee badge
                                            May 5, 2017

                                            Even I am looking for it. Kindly provide those to me as well. Thanks, Puneet

                                            - Puneet Nebhani

                                              JournalDev
                                              DigitalOcean Employee
                                              DigitalOcean Employee badge
                                              August 9, 2017

                                              I too expecting the same from you Ram.

                                              - joe sagayaselvam

                                                JournalDev
                                                DigitalOcean Employee
                                                DigitalOcean Employee badge
                                                January 31, 2017

                                                It is very helpful to learn about Spring Boot. Clearly mentioned each point. Thank you so much…

                                                - Laxmi

                                                  JournalDev
                                                  DigitalOcean Employee
                                                  DigitalOcean Employee badge
                                                  March 30, 2017

                                                  Nice tutorial, it gives good information to create application.

                                                  - Sudhir

                                                    JournalDev
                                                    DigitalOcean Employee
                                                    DigitalOcean Employee badge
                                                    March 30, 2017

                                                    very good explanation.

                                                    - Parag

                                                      JournalDev
                                                      DigitalOcean Employee
                                                      DigitalOcean Employee badge
                                                      July 6, 2017

                                                      Nice tutorial o spring boot … After going through it , having a overview of Spring boot Expecting more concept on it as it suggest how to develop but unable to understand how it works internally… it will be good if share more knowledge on theory and concept of this Spring boot topic

                                                      - Saurabh

                                                        JournalDev
                                                        DigitalOcean Employee
                                                        DigitalOcean Employee badge
                                                        November 20, 2017

                                                        Hi Pankaj, Please help out on how to deploy springboot application in IBM websphere Thanks in advance Regards, R Sridhar

                                                        - sreedhar

                                                          JournalDev
                                                          DigitalOcean Employee
                                                          DigitalOcean Employee badge
                                                          December 7, 2017

                                                          Very Very good Explanation . A Basic Of Spring Boot in a simpler fashion. Nice Job Man

                                                          - Inderjeet Singh

                                                            JournalDev
                                                            DigitalOcean Employee
                                                            DigitalOcean Employee badge
                                                            March 1, 2018

                                                            Very good reading to begin with Spring Boot. Thanks

                                                            - Hasanga

                                                              JournalDev
                                                              DigitalOcean Employee
                                                              DigitalOcean Employee badge
                                                              June 12, 2018

                                                              Hi there! I wanna thank you a lot for this tutorial. It was so great. It helped me so much. But I have one question. Which version of spring boot did you talk about? Is the version matter? or all are the same at this point? Thanks Have nice

                                                              - Nahid

                                                              JournalDev
                                                              DigitalOcean Employee
                                                              DigitalOcean Employee badge
                                                              June 12, 2018

                                                              There are very small changes here and there but the core concepts remain the same.

                                                              - Pankaj

                                                                JournalDev
                                                                DigitalOcean Employee
                                                                DigitalOcean Employee badge
                                                                September 3, 2018

                                                                Thanks a lot mister!

                                                                - Madicoye DJIBA

                                                                  JournalDev
                                                                  DigitalOcean Employee
                                                                  DigitalOcean Employee badge
                                                                  September 10, 2018

                                                                  Thanks for nice post. But one thing Spring Boot really a Frame work on top of Spring Frame work. Or it’s a way to create spring application in java and Groovy languages same as spring with zero or minimal configurations.

                                                                  - Tamsheel Khan

                                                                    JournalDev
                                                                    DigitalOcean Employee
                                                                    DigitalOcean Employee badge
                                                                    September 29, 2018

                                                                    Spring boot is not a framework. It is built on top of Spring framework to avoid manually writing the configurations and boilerplate code. This is my understanding. Please feel free to correct me.

                                                                    - Anji

                                                                      JournalDev
                                                                      DigitalOcean Employee
                                                                      DigitalOcean Employee badge
                                                                      December 19, 2018

                                                                      Great article for the beginners, if any one wants a complete and professional Spring boot Application based on Spring Boot 2, Spring MVC5, Gradle 5, JUnit 5, Mockito, Exception Handling all in one, and many more, get it on github(https://github.com/MFaisalHyder/spring-boot-app). Kindly fork it, star it and do make pull requests to make it even better :) World needs more people like you to help open source community ! :)

                                                                      - Faisal

                                                                        JournalDev
                                                                        DigitalOcean Employee
                                                                        DigitalOcean Employee badge
                                                                        January 6, 2019

                                                                        Hi Ram, Can you please share the MICRO SERVICES TUTORIAL.

                                                                        - Ravi

                                                                          JournalDev
                                                                          DigitalOcean Employee
                                                                          DigitalOcean Employee badge
                                                                          May 8, 2019

                                                                          very good tutorial for spring boot beginners but you should add more detailed information about spring boot.

                                                                          - ashish gupta

                                                                            JournalDev
                                                                            DigitalOcean Employee
                                                                            DigitalOcean Employee badge
                                                                            November 25, 2019

                                                                            Nice explanation! Disadvantages of micro services is not mentioned elaborately. Can you post the disadvantages of micro services.

                                                                            - SHARATH KUMAR

                                                                              JournalDev
                                                                              DigitalOcean Employee
                                                                              DigitalOcean Employee badge
                                                                              February 12, 2020

                                                                              Spring is widely used for creating scalable applications. For web applications, Spring provides Spring MVC which is a widely used module of spring which is used to create scalable web applications. It is an amazing tool that helps you to get enterprise-grade applications up and running quickly without having to worry about configuring your application correctly and safely.

                                                                              - Shivam Verma

                                                                              JournalDev
                                                                              DigitalOcean Employee
                                                                              DigitalOcean Employee badge
                                                                              January 5, 2021

                                                                              Thank you, Captain Obvious!

                                                                              - Aidar

                                                                                Try DigitalOcean for free

                                                                                Click below to sign up and get $200 of credit to try our products over 60 days!

                                                                                Sign up

                                                                                Join the Tech Talk
                                                                                Success! Thank you! Please check your email for further details.

                                                                                Please complete your information!

                                                                                Become a contributor for community

                                                                                Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

                                                                                DigitalOcean Documentation

                                                                                Full documentation for every DigitalOcean product.

                                                                                Resources for startups and SMBs

                                                                                The Wave has everything you need to know about building a business, from raising funding to marketing your product.

                                                                                Get our newsletter

                                                                                Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

                                                                                New accounts only. By submitting your email you agree to our Privacy Policy

                                                                                The developer cloud

                                                                                Scale up as you grow — whether you're running one virtual machine or ten thousand.

                                                                                Get started for free

                                                                                Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

                                                                                *This promotional offer applies to new accounts only.