[MUSIC] With Spring we create a series of controller objects, That have various methods that we want to have invoked by the web container, which is going to be routing them. And to do that, we make sure we set up a web container with a dispatcher servlet that Spring provides. And then it decides which requests go where, and the web container routes requests to the dispatcher servlet. Now, as you can imagine, if we want to set all of this infrastructure up from scratch, we've got to do a whole bunch of different things. One is we've got to provide the web container with routing information, which can be done with something like web.xml, or by calling various method calls to tell the web container how to route requests. We've got to provide routing information to the dispatcher servlet in order for it to know about our different controllers. And we do that with the annotations. So these are usually annotations. But, we still have to have the web.xml or some configuration file that tells the web container to get set up. We also have to do the work of setting up the web container. So we might have to set up Tomcat, which is a web container, or Jetty, which is another one. And so we'll have to set up the web container somewhere. And then we'll have to install our application with a web.xml. And then all of this other stuff comes into play. And it takes a lot of work to set all of these things up. So Spring, one of the sub-projects of Spring is a project called Spring Boot that is designed to make it really easy to set all of these stuff up for a web application like this that we're building. Spring Boot will automatically configure all of these various parts of our application, so that we can focus on writing in our controllers and putting the logic in them. So, this is where Spring Boot allows us to focus is where the actual value is. All of this stuff related to our video service, which is the logic in these controllers. And, Spring Boot helps to automate a lot of this set up. So this is the stuff that Spring Boot automates, is the setup of this tier in front of all of our controllers, because really, all we want to do is focus on writing controllers. We don't want to focus on all of this setup stuff in addition to writing our controllers. And so Spring Boot makes this happen automatically. And it does it in a really smart way. We can go and specify as many of the different parts of this configuration as we want, or as few of them as we want, and Spring Boot will automatically fill in the details. So if we specify certain parts of this configuration, Spring Boot will use that information, and then build everything else around it. If we don't specify anything, we just do the simplest bits of configuration that Spring Boot needs, it'll automate everything in here and make appropriate decisions about the way to configure it. A Spring Boot application has a fairly simple structure, at least initially. We do two things in Spring Boot applications, if we're writing a web application, at least. One, we create our set of controllers that are just Java objects. And this is where most of the logic resides for our application. And then the second piece is we create a class called Application, typically. This is a naming convention that is often used, but you can call it something else if you want, you just have to annotate it properly. And this is where we define the configuration of our particular application. So, this is where we define our controllers potentially, or we tell Spring to automatically go and discover them, and configuration. So we can go and override defaults that Spring Boot will create. Now what we do in order to launch Spring Boot is this application has a traditional main method, a public static void main method that is going to be invoked from the command line. And, in this main method, what we do, is essentially invoke Spring Boot. And we do that, typically, by doing something like SpringApplication.run, and passing then our application configuration here. So this is the simplest sort of organization of a Spring Boot web application. We have the appropriate libraries in our class path to launch Spring Boot, and then we have an application class that defines some minimal configuration that we're interested in defining. And then we just tell SpringApplication.run and we provided it our application class. And Spring, from that point, takes over and it does a whole variety of things. But some of the most important things are, it's going to set up the container, the web container, And it's going to be an embedded web container. It's going to discover, Our controllers. It's going to set up the dispatcher servlet. And I'm just going to abbreviate this dispatcher. And then it's going to, we're going to set the web container, we're going to discover our controllers, we're going to set up that dispatcher servlet, and we're going to tell it about our controllers. And then it's going to go and do any other configuration that we've specified, like connecting to databases or other stuff. So, So, as you can see, Sprint Boot is automating a huge amount of our work for us. It's setting up the web container, it's finding our controllers, it's setting us the dispatcher servlet, telling the web container about the dispatcher servlet, telling it to which requests to route to the dispatcher servlet. And by default, it's going to route all requests to the dispatcher servlet. And then it's telling the dispatcher servlet about our controllers, and then doing any other configuration stuff. And all we had to do was write our controllers, which contain the logic that we care about, and write this application.java class to tell Spring Boot which pieces of the configuration we want it to override from it's default. So we'll give it some initial information, some hints that it needs to go and get its job done. And then it will take care of all of the rest of this complexity. So, for the rest of the course, most of what you're going to see in the projects and the example code is that there will be an application.java class that you should always go and look for. And that's going to define the core of the application, and it'll define that configuration information. And then from there, we'll probably have a bunch of controller objects, which are just plain Java objects, that will provide various pieces of the logic for our application. And the application is the part that's tying all of this together. It's the part that's telling Spring Boot where our controllers live or where to go and look for our controllers, how to construct them. And as we'll see, Spring can automatically instantiate our objects for us and provide them the correct parameters and references to other objects they need to get their job done. So, Spring is going to go to automate all of this construction effort and automate this configuration of our web container and the dispatcher servlet and the connections from our dispatcher servlet to our controllers. So at the end, what we do is we just focus on this part. We focus, And Spring Boot does this. So this is the automated part, and this is our manual part that we have to do as developers. So whenever you see one of the applications, don't look for the application.java file, figure out what it's telling Spring Boot to do, what is it configuring Spring Boot for? And it'll also give you a hint as to where the key controllers are, or other objects are that are going to participate in this application and provide some logic.