Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to use main method when we develop web application using spring boot?

I am new to the Spring boot. I have been practicing Spring Boot with the standalone application in which I used the main method. since the Main method is the entry point. Now I am going to work with a Web application.

Moreover, We don't need to use the main method in servlet, struct and spring MVC for the web application.

Is it really necessary to use the main method in a spring boot web application?

@SpringBootApplication
public class Example  {

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

}
like image 237
Divya Avatar asked Oct 17 '25 15:10

Divya


1 Answers

Spring boot supports two modes of work:

  • using embedded server (tomcat, jetty, whichever you choose). In this mode, you need a main method to start it
  • using external sever. In this mode, you need to pack your project into a war file, in the old fashion way. On this mode a main method is not required
like image 82
Nir Levy Avatar answered Oct 20 '25 08:10

Nir Levy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!