Spring Boot Tutorial For Beginners [2021]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back in this section let's start with learning spring boot what do we want to do in this specific section we want to build a hello world app in the modern spring boot approach and we would want to get hands-on with spring boot and learn some of the most important spring boot concepts we want to understand why do we need spring boot how does spring boot make it easy to develop spring based applications how does spring boot makes it easy to develop micro services we want to understand the terminology with spring boot as well spring initializer auto configuration startup projects actuator developer tools there are a lot of terminology which is associated with the spring framework let's try and get hands-on and understand all that terminology in this specific section are you excited to learn spring boot i'll see you in the next step welcome back let's get started with creating a simple springboard project how do we create springboot projects the easiest way to create springboot projects is to use the website spring initializer you can create a variety of spring projects using spring initializer website you can go in here i recommend you to choose all the defaults maven java and i would recommend you to use the latest released version of spring boot i recommend not to use any of this snapshot or milestone releases a milestone release is identified by m1 m2 or m3 do not use them over here i can see the latest release is 2.4.4 there is another release which is present 2.3.9 but this is old so i would recommend you to choose the latest released version by the time you watch this video if you'd see 2.5 or 2.6 or 2.7 choose the latest version which does not have either snapshot or m3 associated with it and i would go in and give group id and artifact id group id and artifact id are the names that we would give to our project this is like the package and the class name so com dot in 28 minutes is a group artifact id i would give learn spring boot i'll choose the defaults for rest of the things and i would add a dependency we would want to build a simple rest api and in spring boot the way you can build rest api is by using spring web so if you type in web you can choose spring web as you can read in here it says build web including restful applications using spring mvc this uses apache tomcat as the default embedded container so we would want to build applications using spring mvc and run them on tomcat as the embedded server so we will choose spring web i will click this and choose it and you can see that spring web is added in here now you can go in and click generate this would create a zip file and this would be downloaded to your downloads folder what i recommend you to do is to unzip that zip file and you can move the unzipped file to some folder on your hard disk you can open up a new workspace in eclipse or you can use existing workspace that you are already using what i would do in here is to import it as a maven project file import existing maven projects and over here i can choose the folder where you extracted the zip file to i've extracted it to this folder and i would say open and you can see a palm.xml in here that's cool you can go ahead and say finish you'd see that within a little while the project would be configured for you if you are having any problems with the import what i would recommend you to do is to make sure that you have the latest version of eclipse installed there are multiple eclipse releases which are released every year so make sure that you are using latest eclipse version and most of the times you should not face a problem now you should see source main java this is where we would write our java code source main resources this is where we would have our application configuration present and we would have source test java where we will write our unit test if you go to memory dependencies you would see that there are number of maven dependencies which are added in these are added in because in our palm.xml we have a few dependencies defined so you can see that we want to develop a web application that's why we added in spring boot starter web so spring boot starter web is something called a starter which is provided by spring boot to help you build web applications and because we added in spring good starter web you would see that there are a lot of dependencies which are present in here we would look into all these in detail a little later all that we need to do right now is go in in source main java open up learn spring boot application class and right click run as java application this would take a little while to launch up this java application and within a minute or so you should see that a new springboot application is launched up for you this step we created a simple springboard project using spring initializer and we were able to quickly launch it up as well in next steps let's start building some functionality let's build a few features and use those features to understand spring boot framework welcome back starting this step let's get hands-on with spring boot to understand the power of spring boot we'll build a very simple rest api expose a url something like this if user sends a request to this url what we want to do is we want to be able to respond back with a simple response back let's get started i'll go in here and what we want to do is to create a controller so i'll say new class and i would put it in package dot courses dot controller so it would be related to courses and it would be a controller that's why i put it in a package called courses.controller and i'll call this course controller and i would say finish we'd want to expose a web url how can we do that we want to expose a simple rest api how can we do that so i can say this is a rest controller so at rest controller and you can do an organizing ports this would import or spring framework web bind annotation rest controller that looks cool now what we want to do when user types in this url we want to send a specific response back so we when user sends a request typically the default request which is sent by users is something called a get and we would want to create a get mapping what is the uri slash courses this is what the user would send this is what the user would send a request to and what we want to do when user sends a request to this i would need to return a response back i'll return a list of courses back so list of course we don't have the course class yet we'll build that very soon i'll call this get all courses and over here what we need to do is to return a list of courses return address dot as list if you are using java 9 or higher you can also use list.off and we want to build a new course so the new course that we would want to create what do we want to be able to do in there we would want to give it a id so id is one let's say the id is one and we want to have a name for the course so let's pick it up from here or you can type it in i don't want to be able to learn microservices and we want the author in 28 minutes that's the course we would want to create and return back right now there are a lot of compilation errors we typed in the code let's fix the compilation errors the first thing i would do is organize imports you need to choose java util list so get mapping is imported in all spring framework web bind annotation get mapping and the other thing which would have been imported in is java util list there are compilation errors on the course class obviously right we did not create the course class yet so what i would do is do go in here and press command one so i'll say create class course and i'll create this in courses dot bean package so com invented means learn spring boot courses b is the package course is the b name let's go ahead and say finish so this is the course class that we want to create and what do we want to do in the course class we would want to have three fields id name and author let's go ahead and create them private long id private string name and prime private string author so these are the three fields that we would want and let's do a right click source generate and you'd be able to go ahead and generate it and you'd be able to go ahead and generate a constructor using fields so let's generate a constructor using all the three fields so we have a constructor which is generated right now let's also generate a two string method so i click source generate and say generate two string and let's use the defaults and create a two string method as well so this would help us to see the details if you want to print it to the console so we now have a course class created and we would want to use this so if you save the controller right now you'd see that it would compile properly if you have a compilation error then make sure that the order is matching whatever you have in the constructor so id name and author over here as well i have id name and author so it all looks good and last thing that i would need to do in the course class before i would be able to run the application is to generate a little bit more code so you need to generate source generate data sensors let's generate only getters so select getters and let's generate the getters for this specific class so you can see that get id get name and get author are generated let's do a format of the class and it looks good right now so we have a course class with the constructor getters and the tostring method defined what we'll do is go ahead stop the application and let's start it again cool the application started up fine let's go in and type in the url localhost 8080 slash courses fingers crossed will it work cool you'd see that i'm able to launch this app you can see the response which is coming back id 1 learn micro services in 28 minutes you might see simple text so if you say view source this is what you would be seeing however i have a chrome extension called json viewer which is installed and because of the extension i can see the response back in a formatted way i can see id is one name is learn microservices and author is in 28 minutes the idea behind this step is to start understanding the power of spring boot with a simple example you can see that within 10 minutes we were able to create a hello world rest api very easily that's what spring boot enables to understand the power of spring boot let's try and understand how applications were built before spring boot in the next step i'll see you in the next step welcome back in this step let's look at how you would have built the same application before the evolution of spring boot let's say you want to build a simple application using spring framework spring mvc and you'd want to run it on tomcat i've made a link available to a sample pawn.xml from our earlier course on spring mvc you'd see that there are a lot of things that are defined in our palm.xml setting up spring web projects before spring boot was not easy you need to define all the maven dependencies and manage versions of framework if you open up this link as you can see in here in the palm.xml you have to define the dependencies and you have to define the versions of the dependencies you can see that the versions keep changing if you want to move from one version of spring to another version of spring you need to make multiple changes in here so you need to manage memory dependencies and the versions for frameworks you would also need to define web.xml file for your web application so if you go to web.xml if you search for web.xml you'd see that there is a web.xml in here where a simple servlet is configured you can see the complex configuration which is involved in configuring something called a dispatcher servlet so you need to configure that and after that you need to define a spring context xml where you define all your beans you need to create something like to do servlet.xml and define component scan and a lot of things in there so you need to go in and let's go if you scroll up a little you'd see to do servlet.xml where we have a component scan defined and a lot of other things defined in here as well other than that you'd also need to install tomcat or you need to configure something called the tomcat7 maven plugin you'd see the configuration for that in the palm.xml over here so you can see that we need to configure a tomcat 7 mav1 plugin and after that you need to build your application and you need to run the application in tomcat as you see in the last step running applications with spring boot is very very easy all that we did was we went to spring initializer we created a simple project and we saw that this project also contained just couple of files not a lot of complexity in that specific project as such and we were able to quickly run the application and we also saw if you look at the logs that this is making use of tomcat as well so there is a lot of magic that spring boot brings in spring boot makes it really really easy to build web applications or rest api or any kind of java applications that you would want to build now that we saw the magic of spring boot let's understand what's happening beneath the hood how does spring boot do its magic there are two important things that you need to understand which are spring boot starter projects and spring boot auto configuration let's get started with understanding spring boot starter projects in the next step welcome back instead let's get started with understanding spring boot startup projects spring boot startup projects are one of the fundamental blocks behind the magic of spring boot the goal of startup projects is to help you get a project up and running quickly if you want to develop a web application the starter you would make use of is spring boot starter web earlier when we created this project on the spring initializer page we chose spring web this is the spring boot starter web that we chose and if you open up the pawn.xml so let's go in and open up the pawn.xml file in here you'd see that there is a dependency on spring boot start of web so if you want to develop a web application with spring boot or if you don't develop a rest api with spring boot the recommended starter is spring boot starter web now what is the magic of this spring boot starter web you can do a control click or a command click and open convert xml for org spring framework boot spring boot starter web if you click that another palm.xml opens up where you would see that there are a number of dependencies which are defined in here whenever you build a web application you'd want to be able to use json you'd want to be able to convert the bean if you look at this course controller what we are doing in here we are writing a list back how is the list getting converted to json if you look at the response that came back it's a json response how is that getting converted the way it is getting converted is through this starter spring boot starter json you'd want to run the application in tomcat this is a starter which enables that you'd want to build the rest api or the web application using this spring mvc framework these are the dependencies which enable us to do that as you can see in here springboot starter web enables you to quickly get started with developing your web applications or rest api there are also other starters which are available if you want to talk to database if you want to use jpa or hibernate in those kind of situations you can use spring boot starter data jpa if you want to talk to database using jdbc you can use springboot starter jdbc if you want to secure your web application or rest api you can use springboot starter security there are a lot of starters which are available there are a lot of starters which are available the best way to search for starters is by going in here and saying add dependencies if i would want to use jpa spring data jpa that's one of the starters which is provided if you want to play with spring security so spring security that that's one of the starters which is provided by spring boot if you're new to developing enterprise applications then words like jpa or jdbc or or security might sound a little new the important thing for you to understand is that if you want to develop any application quickly you can just add in a starter and you'd be able to get started with that specific project as we saw in spring boot starter web each starter manages a list of maven dependencies and the versions for different kinds of applications we saw the example for web application which is spring boot starter web you can see list of dependencies and their versions all these are automatically managed by this spring boot starter web so spring good starter web contains the frameworks which are typically needed by your web applications so spring web mpc spring web spring boot starter tomcat or springboot.json in this step we started demystifying some of the magic behind springboot if you use starters you don't need to really configure all the frameworks that are typically used to develop your specific application you can just configure a simple starter in your form.xml and that's it you get all the dependencies for free but you might be wondering is it sufficient if i just bring in the dependencies don't we need to configure them who does that that's what we'll be looking at in the next step welcome back in this step let's look at spring boot auto configuration spring boot starter projects define a set of dependencies if i need to develop a web application i need a b c d and e so the starter defines a b c d and e but these frameworks might need a lot of configuration if you want to start a spring application you would want to launch a application context you would need a lot of configuration who provides all that configuration that's where spring boot auto configuration comes into picture spring boot provides the basic configuration that is needed to run your application using the frameworks defined in your maven dependencies once we added in these starters once we added in starters we would have a number of frameworks or number of classes that are available in our class path so this is where we have a lot of jars and these jars contain a lot of classes and what springboot does is based on these classes which are available on the class path it would provide auto configuration so auto configuration is decided based on which frameworks or which classes are in the class path and what is the existing configuration you might provide additional configuration on top of the auto configuration spring provides auto configuration you can override with your own configuration as well so spring boot auto configuration looks at these two things what classes are available in the class path and what configuration have you provided and it will use this information to provide its own auto configuration where is all the auto configuration logic defined all the auto configuration logic is defined in a jar called spring boot auto configure so this has a lot of classes and all these classes are responsible for auto configuration now you want to look at what's happening behind auto configuration how can you do that what is being auto configured i would want to find that out how do you do that i'll go to application.properties so i'm opening i'm opening up application.properties which is present in here source main resources application.properties and i would say logging.level.org dot spring framework is equal to debug we are setting the logging level to debug i would stop the application and start it up so this would print a lot more information into the log you can see that there is a lot of debug log which is being printed and you would see that there is a lot of auto configuration which is being done you can see there are positive matches for auto configuration and there are negative matches for auto configuration let's pick up one of them let's pick up dispatcher servlet auto configuration i'll open the type so ctrl shift d or command shift t you can open the type up and you can look at the details behind that so if you go to dispatcher servlet auto configuration the important things in here are this is enabled only if it's a web application so only if it's a web application i would want to create a dispatcher servlet auto configuration and this is conditional on class an additional condition so this is first condition this is the second condition what is the second condition dispatcher servlet.class should be available on the class path what is defined in spring boot auto configuration jar is the conditions under which a specific auto configuration is applied and when we are starting our application up spring boot would look at all the classes which are available and based on the classes and the configuration that is available it would auto configure a lot of things for whichever things the conditions matched they are called positive matches so you can see that for dispatcher servlet auto configuration it matched so the conditional class which is dispatcher servlet it was found on the class path it's also a web application so that's why this is auto configured similar to that you would see that there are a lot of other things which are auto configured you can see that because this is a web application something called an error mvc auto configuration is enabled as we looked right now when we are using spring good starter web the following details are auto configured we saw dispatcher satellite auto configuration you would see that an embedded servlet container is also auto configured we want to use tomcat to run our web application this is auto configured by default when we are using spring boot startup web there are also default error pages which are auto configured so if you search for error mvc auto configuration and search for it you'd see that there is default error configuration that is provided what is the use of that let's say i type in an error url let's type in a url something like this which is not defined in the application you'd want to return some nice error to the user and that is the requirement which is typically present in every application and that's the reason why spring boot auto configures it it automatically returns a 404 it says this is not found this url does not exist on the application so what we are returning back is a proper error message to the user so this is an example of something which is auto configured by springboard for you the other thing which we also saw when we built our application is the been to json conversion in our in our course controller.java we are writing a javabean back a arraylist back who is converting this to json this is converted by a framework called jackson and this is auto configured for us so the two most important parts of the magic behind spring boot is spring boot starter projects and spring boot auto configuration spring boot starter projects define the different dependencies that are needed to build different kinds of applications and spring boot auto configuration would look at those dependencies would look at all the classes which are available and it would provide auto configuration that is typically needed with that kind of application if i'm developing a web application i would want to configure a servlet i would want to configure a server where i would want to run the application in i would want to configure default error pages i would want to configure to and fro conversion from json all that configuration is automatically done so that you focus on your business logic the end objective of spring boot is to help you focus on the application you are building not worry about the frameworks or the configuration that is needed by the frameworks i'm sure you're having a wonderful time and i'll see you in the next step welcome back in this step let's further understand what's happening behind our spring boot application if you open up the learn spring boot application class you'd see that this is where this spring context is being launched up this is being launched up by using springapplication.run and this would launch up this class the configuration which is present in this class as a spring context if you open up springboard application you would see that there are three important annotations which are present in here i'll copy these out and paste them in here so the annotations which are present in here are spring boot configuration at enable auto configuration and also a important one called component scan springboard configuration identifies that this is a configuration file this indicates that this is a class which provides spring boot application configuration typically in spring framework if you are defining your own configuration you can put add configuration on top of it and for spring boot applications and for spring boot applications the annotation is spring boot configuration the next thing is to enable auto configuration we saw auto configuration in action in the last step by default every kind of auto configuration is enabled however if the auto configuration with spring boot does not match your requirements you can go and disable specific kinds of auto configuration as well you can go in here you can go to at enable configuration and you'd see that you can exclude certain classes so you can exclude specific auto configuration classes that should not be applied so if you go further down you can see that there are a lot of auto configuration files if you don't want to use certain auto configuration files you can exclude them so if you are not happy with the default auto configuration which is provided you can exclude it and you can provide your own configuration as well the third important thing is a very important feature of the spring framework using component scan you can specify the packages where the spring framework can scan for different kinds of components so you can specify a package like this and spring framework would search this package for components or beans it would want to manage by default the component scan which is done by spring boot would be done on this specific package so comm dot in 28 minutes that learn spring boot is the package on which the component scan will be done on let's organize imports in here and what i would recommend you to do is to actually build one more method in here as an exercise what i would want to do is for enough build another method which would have the url courses slash one so http colon slash localhost colon 8080 slash courses slash one and what i would want to return is just one course back over here we are writing a list of courses back so i can say control c and add another course so let's say i would want to add another course because we are list sending a list back you can have multiple thing back so let's say i would want to learn full stack with angular and react so that's what i would want to do i can save this and you would see that if you stop and restart the server this would return two elements back however what i would want to do is return just one element back we want to return this specific course directly as part of this exercise you can pause the video and try that as an exercise now the way we can do that is i would just copy and paste this in i'll i'm a little lazy so let's take the lazy approach so slash courses what we want to do is to do slash courses dot one and what you want to do is to get a specific course so get course details and let's return just one thing back let's return the one with the details back i need to change the return type so it's not a list of course it's directly the course and i would stop and start the application and you should see your new service up and running so it's a debug level so a lot of log and if i go to courses i can see the courses courses slash one cool it returns this specific thing back right now we have not implemented other things like courses slash two or courses three for that we need to make use of a few other spring mvc concepts like path variables let's not worry about them for now but now important thing for us to understand is spring boot makes it very very easy to build any kind of application that you would want to build it helps you to focus on your business logic and you don't really need to worry about any other configuration that is typically needed let's see a lot more about springboot in the subsequent steps i'll see you in the next step welcome back in this step let's talk about embedded servers if you go a few years back the way you deploy your application is first you'd install java and then you'd install a web server or an application server there are a number of web servers or application servers which are available like tomcat weblogic or websphere and if i would want to install a java application or a bar file on the web server i would need to first install java and then install the web server and only after that i can go ahead and install my application var so to run a web application a few years back you needed to install java and install a web server on an application server and then you would go ahead and deploy the application so you'd see that there are a lot of complex steps which are involved so running java applications a few years back was very complex however compared to that running other applications for example node.js applications was very very simple springboot makes running your java applications very easy how does it do it through the concept of embedded server when you are using embedded server all that you need to do is to install java and then you can go ahead and run your jar file how is this possible this is possible because your jar file contains the server inbuilt your jar file contains the embedded server in the example that we have been running until now the jar file contains tomcat right inside the jar file and therefore you only need java installed you have the jar file if you have java installed that's more than sufficient to go ahead and run the jar file let's see that in action right now let's build a jar file how can i build a jar file for this particular project the way you can do that is by going in here right click run as maven build and i would say the goal as install i'll say clean space install and say run so this would do a mvn clean install and it would build this specific jar the first time we are building a jar it does take a long time so there are a lot of steps in building the jar all of them are provided by default for you and you can see that a jar is automatically created for us you can see that a jar is created in this specific path you can see that installing this specific thing so if you go to the command line and pick up this particular folder so you'd see that there is a target folder which is at the end so i'll pick that up so if you do to cd to that folder and do a ls you'd see that there is a jar file which is present in here so learn spring boot 0.0.1 snapshot.jar so this jar is created for us and this jar automatically contains tomcat and so to run this all that i need to do is to say java hyphen jar and paste that in learn spring boot 0.0.1 snapshot.jar and you'd see that the application would launch up automatically you can see that the application start has failed because port 8080 is already in use i have this application running here so let's kill this so let's kill the application and make sure that we don't have anything running in here and you can go in and execute the command again java hyphen jar so that's basically how you can run your jar files and you can see that the application is up and running and you'd be able to easily go in and execute the urls that you would want to execute as we saw earlier the tomcat is coming in because of spring boot starter web so if you go to spring boot startup web and click open pawn.xml for this so control click and select this you would see that over here we have springboot starter tomcat this is the starter which brings in tomcat so tomcat would be built into our jar and that is what it would be used to launch up our application josh long is one of the popular spring developer advocates and one of the statements that he made that i really love is make jar and not var jars make it really really easy to run your applications so make jar and not var the embedded server we have been using until now is tomcat if you want to use other embryo servers there are starches for them as well spring boot starter jetty is for jetty swing good starter under 2 is under 2. in the step we understood the concept of embedded servers we understood why we need to make jar and not var welcome back starting this step let's explore a few more spring boot features let's start with spring boot actuator one of the important goals of spring boot is to help you build production ready applications very easily one of the typical needs in production is to be able to monitor your application to be able to look at the metrics behind your application and one of the options springboot provides for you to be able to easily manage your application in production is spring boot actuator spring good actuator provides you with a number of endpoints you can look at all the list of spring beans in your application you can look at the application health information you can look at the different metrics behind the application and you can also look at the different request mappings you have as part of your application let's look at this in action right now so how do i get started with spring boot actuator all that i need to do is copy this and paste it in and say spring boot starter actuator so similar to spring boot starter web we have spring good starter actuator let me stop the jar file i'm running in here so i don't really want to run it as a jar anymore i'll do a ctrl c to shut down that and i'll go back to running it from here so we added the actuator to our maven pawn.xml it would automatically download the charts for us and it would make them available to the application and i can go ahead and run this so let's go ahead and launch it up learn springboot application is what we want to launch it up the console is the application is launched up and the url for actuator is localhost 8080 slash actuator and you can see that by default actuator provides three different urls as i said earlier i have a plugin called json viewer which is installed this is a response which is typically written back from actuator and the json viewer makes it available in this specific way so it's formatting it so that i can easily invoke the urls and things like that if you want you can go ahead and install the json viewer chrome plugin as well now you can go in here if you want to find out the health of the application you can say you can see that the application is up and running if you want to see any information behind the actuator actually this does not really return anything back if you open that up you'd see an empty thing back but this is one of the apis which are provided by actuator as you can see in here by default only a few apis are enabled but there are a lot more things that you can enable on your actuator the way you can enable them is by going to application.properties so source main resources application.properties so in source manager resources we have the application.properties what i would do is i would turn off the debug logging there's too much log coming in so let's turn that off and let's add in a simple configuration to enable all actuator endpoints actuator is related to management we want to manage our application and what we want to do is to enable all the endpoints that's what we are doing in here management dot endpoints dot web dot exposure dot include is equal to star once you add this and you stop and start the server let's start it again and if you go and refresh the actuator url you'd see that there are a lot more urls which are present in here so you can go ahead and say actuator beans and this would show all the spring beans which are created so we have created a controller and for this there would be a spring bean which would be created so if you search for course controller you should see a spring bean which is created for you i'll close this i close the other ones as well and go back to actuator you can see the health information you can see details about the environment as well so if you go to env url you can see the details i'm running this server on port 8080 and you can also see the java version which is being made use of what is the class path and a lot of details about the environment where the application is running in you can also get a lot of metrics so actuator metrics and you can see a lot of metrics related to the application which is running let's pick up one of these metrics from here let's say i want to find out how many requests have come in until now i can go to http server request so matrix slash http server request and this would show me how many requests have come in right now it's saying five requests and if you execute a few more requests i'll refresh the actuator url again and refresh the http server request you can see that there are more requests so there are now nine requests so you can look at the metrics related to different things using actuator as well one of the important recommendations that i have for you is to enable only the things that you would make use of right now we are doing a star this would enable everything however you always have the option of enabling specific things that you would want to use only so for example if you want to expose let's say only the health information i can put health in here and if you want to let's say also expose the metrics so i can copy matrix in here and say metrics so this would help you to configure and enable specific urls only and now if you stop and start let's go ahead and start this up and refresh actuator you'd see that only health and metrics are now enabled in this step we played around with spring boot actuator i'll see you in the next step welcome back in this step let's pray around with one of my favorite features in spring boot this is called spring boot dev tools let's see what features it would bring in spring boot dev tools increases developer productivity think about this why do we need to restart the server for every code change so over here i would go in and add in a dependency org spring framework boot spring boot dev tools one of the important things about devtools is it's not useful in production you are not going to go and make code changes directly in production so that's the reason why you don't want it to be part of your deployable unit the way you can do that is by saying scope as runtime and i would go ahead and say save what is the magic that it would enable before we can see the magic for one time alone we have to stop so that it would actually pick up the dependencies and then click start again so this would start the application up and this would return back and if i look at the course controller what is the details that are retrieved by courses slash one right now if i invoke courses slash one ids one learn microservices in 28 minutes let's say i would want to change this i want to add learn microservices one and save this what would happen now you can see that the server is automatically restarted so it automatically picks up the change and if you refresh you'd see that the details are automatically picked up so the important thing for you is that you don't really need to keep restarting the server each time whenever you're making a code change in your java files as soon as you make the code change the change would be picked up by the server and you can directly run your urls and check if your change is working that's the magic of devtools now a warning if you change bom.xml if you add a new dependency in pawn.xml or something like that or if you are removing a dependency from android xml devtools will not be able to pick that up what you need to do is to stop and start the server every time you make a change in power xml however any java changes you make any changes you make to your spring components all those changes will be automatically picked up by devtools that is one very important thing to remember a lot of times i see questions where students go and add a dependency into the pawn.xml and you would not see it reflect immediately the reason is because if you make a change in the pawn.xml for it to reflect even if you are using devtools you need to stop and start the application in this step we looked at spring boot dev tools it helps you increase your productivity and save a lot of time i'm sure you're having a wonderful time and i'll see you in the next step welcome back whenever we talk about spring framework or spring mvc or spring boot you'd see that there are a lot of frameworks available and you are often confused what is the role of which one what is the role of springboard what is the role of spring mvc and what is the role of spring framework the idea behind this step is to give you a little bit more clarity into what these frameworks are all about the core feature of spring framework is dependency injection you'd want to define your beans and auto wire your dependencies that's the most important feature of the string framework so things like add component at auto wired ioc container application context component scan these are all the things that think framework enables spring also provides a number of modules and a number of projects so if you want to develop a web application it provides a spring webmpc module if you don't want to configure a lot of things and quickly build projects it provides a project called spring boot so spring mvc is a spring module it's a spring module which helps you to build web applications in a decoupled approach so spring mvc is all about dispatcher servlet model and view view resolver whenever you're building a web application with spring mvc you need to configure a lot of things and that's the problem that spring boot aims to solve it helps you to build production ready applications quickly with spring boot you don't really need to manually configure any of these as soon as you add in spring web starter all these things are auto configured for you so you don't really need to worry about how to configure a framework you can start building your business logic so springboot provides a number of starter projects which make it easy to build a variety of applications and it provides auto configuration so that you don't really need to manually set up a lot of things when you are creating a new project springboot also provides you with a number of production ready non-functional features it provides something like actuator which makes it easy to monitor your applications it also provides features like embedded servers you don't really need to worry about installing java then installing a web server and then running your application because tomcat or embedded tomcat is already part of your jar you can directly install java and directly run your application it also provides you features like default error handling when you execute a non-existing url it would give you a proper error message spring framework is all about dependency injection spring mvc is a spring module which help you to build web applications but when you use spring mvc there is a lot of configuration that is needed spring boot helps you to avoid that configuration it helps you to build applications quickly springboot makes it easy to build your applications through startup projects and auto configuration i'm sure you're having an interesting time and i'll see you in the next step welcome back the goal of this section was to provide you with a 10 000 feet overview of the spring boot framework we were focused on helping you understand the terminology in a hands-on way we played with a few startup projects and we also looked at auto configuration we also understood the use of actuator and tools the biggest advantage of spring boot is that it helps you get started quickly with developing your applications you don't need to worry about a lot of configuration you just add in a few startup projects and you can immediately start focusing on your business logic it also provides you a number of production ready non-functional features i am sure you had an exciting time in this specific section and i'll see you in the next section
Info
Channel: in28minutes Cloud, DevOps and Microservices
Views: 49,655
Rating: undefined out of 5
Keywords: spring boot, learn spring boot, spring boot tutorial
Id: 19lZkM7Dr-c
Channel Id: undefined
Length: 51min 32sec (3092 seconds)
Published: Wed Apr 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.