Spring Boot Initializr with IDEs (via Spring Tool Suite)

Hello friends lets discuss another important components Spring Boot Initializr of Spring Boot, it is a quick way to create spring boot project structure. In this article we are going to explore about Spring Boot Initializr with STS IDE. Spring Boot Initializr is used to quick start new Spring Boot Maven/Gradle projects within no time. It generates initial project structure and builds scripts to reduce Development time.


Spring Tool Suite3 has long been a fantastic IDE for developing Spring applications. Since version 3.4.0 it has also been integrated with the Spring Initializr, making it a great way to get started with Spring Boot.

Related tutorials previously we have discussed

Create a new Spring Boot application in Spring Tool Suite

Step 1: Select the New > Spring Starter Project menu item from the File menu.


Step 2: We will get the following “Spring Starter Project” Wizard to provide our project related information.


Step 3: Please provide our Spring MVC Maven Web Application Project details as shown below and Click on “Next” Button


Step 4: Click on “Finish” button to create our new Spring Boot Project.

Step 5: Now Spring STS Suite creates a Maven Project and downloads all required Jars to our Maven Local Repository.


Step 6: Once the project has been imported into your workspace, you’re ready to start developing your application.

Step 7: Execute Spring Boot Application Run As > Spring Boot Application from the Run menu.




Step 8: Access our Spring MVC application with “http://localhost:8080/MySpringBootApp” and observe the results


SpringApplication:


The SpringApplication class provides a convenient way to bootstrap a Spring application that will be started from a main() method. In many situations you can just delegate to the static 
SpringApplication.run method:

  • SpringApplication is one of the Spring Boot API classes.
  • SpringApplication class is used to bootstrap a Spring application that will be started from a main() method


package com.dineshonjava;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MySpringBootAppApplication {

 public static void main(String[] args) {
  SpringApplication.run(MySpringBootAppApplication.class, args);
 }
}


MySpringBootAppApplication class is annotated with @SpringBootApplication annotation.

@SpringBootApplication does the following things:

  • Because of @Configuration annotation, It scans for @Bean methods to create beans.
  • Because of @ComponentScan annotation, It does component scanning (Components means Beans annotated with @Component,@Service,@Repository,@Controller etc).
  • Because of @EnableAutoConfiguration annotation, It triggers Spring Boot Auto-Configuration.

When we run MySpringBootAppApplication class main() method, it make a calls to “SpringApplication.run()” method. Then this call done following things

  • This call is used to create “AnnotationConfigEmbeddedWebApplicationContext”.
  • This “AnnotationConfigEmbeddedWebApplicationContext” instance is used to create an instance of “TomcatEmbeddedServletContainerFactory” class.
  • This “TomcatEmbeddedServletContainerFactory” is used to create an instance of “TomcatEmbeddedServletContainer” class.
  • TomcatEmbeddedServletContainer” instance starts a Tomcat Container at default port number: 8080 and deploys our Spring Boot WebApplication.



Summary
Congratulation!!! Here we have learned how to create Spring Boot Application with Spring Boot Intilizr via STS IDE. And also discussed code flow of run this spring boot application.



Happy Spring Boot Learning!!!


Spring Boot Related Topics
  1. Spring Boot Interview Questions and Answers
  2. Introduction to Spring Boot
  3. Essentials and Key Components of Spring Boot
  4. Spring Boot CLI Installation and Hello World Example
  5. Spring Boot Initializr Web Interface
  6. Spring Boot Initializr With Spring Boot CLI
  7. Installing Spring Boot
  8. Developing your first Spring Boot application
  9. External Configurations for Spring Boot Applications
  10. Logging Configuration in Spring Boot
  11. Spring Boot and Spring MVC
  12. Working with SQL Databases and Spring Boot
  13. MySQL Configurations
  14. Spring Data JPA using Spring Boot Application
  15. Spring Boot with NoSQL technologies
  16. Spring Cache Tutorial
  17. Spring Security Tutorial with Spring Boot
  18. Spring Boot and MongoDB in REST Application
  19. Complete Guide for Spring Boot Actuator
  20. Microservices with Spring Boot


Labels: