Hey there, welcome back friends in this video we will talk about this particular file servlet initializer not this particular file gets created automatically and when we try to build our application there is no real purpose no real place where we have used this file. So why this file is getting generated and what is the purpose behind this file. Now friends imagine this thing, if I open this particular what we say file, this file is responsible in running our application. Right so in here this statement is spring application dot run and then we are giving the class and ogs which is cool what this other file is doing servlet initializer. If we check this particular file, again, this is not doing anything but start of our application. Now, why have you need to file so which will restart our application or do similar things.
Now, as the name suggests, there is a slight difference between these two files, this particular file will start run the application, whereas the servlet initializer will initialize the servlet. Now, when we directly run our application by right clicking this application and run this as Java application or Spring Boot app, we are making use of embedded Tomcat. Now we have already seen that spring comes with embedded Tomcat jars, and really not to worry about any third party servers in order to deploy a Spring Boot application. A Spring Boot application already have a web server built into it. Now this is coolest stuff, but for example, we will do Like to extract this particular application as a war file maybe. And then we would like to deploy this application on an actual web server, then what happens?
Now if if you would like to create a war file out of this application and then deploy this application, then this servlet initializer will come into picture. Now friends, even though this particular file servlet initializer is doing nothing for us. And this file is optional, but definitely It is recommended to keep this file into your project. Maybe later down the line, we would like to export our application as a war file and deploy that on actual web server. So for that matter of purpose, it is good to keep this file in place and definitely this file is auto generated. So we need not to worry about creating this file again.