A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Spring Boot startup

How does Spring Boot startup?

How does Spring Boot startup?

In starting the spring boot, it setup default configuration, starts spring application context and perform class path scan as well as starts tomcat.
There is SpringApplication class that have static method run, which takes argument of main class from where application will start.

Spring Boot Startup example:-





              import org.springframework.boot.SpringApplication;
              import org.springframework.boot.autoconfigure.SpringBootApplication;
  
              @SpringBootApplication
              public class MainClassForSpringBootApp{
                
                  public static void main(String[] args) {
                  SpringApplication.run(MainClassForSpringBootApp.class, args);
                  }                
              }


 

What is Concept behind the starting Spring Boot?

Setup default configuration: Spring Boot starts with @SpringBootApplication in the public class mainclass and configure to bootstrap the application.

Starts spring application context:There is a main method in main class, from where our application will start and so that we have SpringApplication.run(MainClassForSpringBootApp.class, args); tha will return and will provide the ApplicationContext Object.

Perform class path scan:@SpringBootApplication annotation use to scan the full package while startup the application and check beans, controller and other coding stuff.

Starts tomcat:Spring Boot provides embedded tomcat to the application and developer should not worry about configuring the server.


Now, we are able to say that there is very good and better concept in Spring Boot while startup as below:-

  • Setup default configuration

  • Starts spring application context.

  • Perform class path scan.

  • Starts tomcat.




Thanks Reader...


LEARN TUTORIALS

.

.