In this step, let's look at my favorite feature. The application is up and running and I would be making a change
here. So I'm changing the mastering spring 5.0 to 5.1.
What would happen, when I execute the service?
The service is still returning 5.0.
The service does not pick the change up because to pick up the change I would need to stop the server and restart
it again. And that's cumbersome, isn't it?
Starting up the
server would take a few steps.
I meanit would take a few seconds and that would waste my time.
How can I get the whole thing to be loaded automatically as soon as I make a code change?
How do I do that?
That's where
Spring Boot developer tools come in.
It's an awesome dependency.
I love it.
I'll copy spring boot starter actuator and I'll put it below test. Spring Boot, it's called spring boot
dev tools.
I just added our dependency on to spring boot dev tools.
It's as simple as that.
I'll wait the whole thing to build. So you can see that it's downloading that dependencies. The project is redthe project
is ready and now I execute it. When I start the server,
You can see that the server is loaded or server started. And now as you did I would get 5.2
obviously because I've restarted the server. But
the great thing from now on is any Java changes that you make would be automatically picke up. So I'm
going back to 5.0. What would happen if I execute this?
One of the things you would see in the logs is that the application is restarting automatically and 5.0
This time let's focus on what's happening in the log.
I'll just clear off whatever log is there. And I'm making a change.
Mastering spring.
5.1.
Let's say. 5.1 is not yet here at the time of creating this video but just having fun. So you can
see that this specific thing is also very efficient at the way it restarts.
You can see that this actually started in two seconds.
The change was picked up in two seconds. I'll stop the application and restart it.
You would see that actually the typical restart when I do a fresh restart on spring boot is about 8 to
10 seconds.
So this is taking about 9 seconds. So if I stop and restart the application it's taking about 9 seconds.
However, if I just make a change directly here. I'llwhat I'll do. actually turn this off. And also let's look at how much
time it takes. So now
how much time did it take?
You can see that this actually takes two and a half seconds.
Pretty cool! Isn't it?
So one of the things that Spring Boot does, Spring Boot dev tools does very effectively,
is it knows that everything in Maven dependencies will not change at all. So it will not load things which
are dependent on these again. It will only load those beans which arewhich are the application beans
again. That's why it takes lesser time
when you make a change. When you restart the server, everything including whatever is in here is loaded
but when you when you make a change in the application only that specific things which are application
related are reloaded again. And that's the reason why you see that it only takes 2 seconds and imagine
the amount of productivity you would gain with this.
So this is almost 10 seconds saved for every change you make.
If you are maintaining any kind of application that's a big productivity boost. So if you are using a Spring
Boot application and if you are not using to Spring Boot developer tools then go ahead and try it.
That's a pretty cool addition, I would think, to Spring Boot. In the step, we looked at Spring Boot dev tools which
is one of my favorite additions to Spring Boot. Until the next video, bye-bye.