What and Why Spring Boot
What is Spring Boot?
What is Spring Boot? There are two words here, Spring and Boot. The first part, Spring is something must be familiar with.
It is the Spring framework, and it is a framework that let you write enterprise Java applications. It is a huge framework that does a lot of stuff, and it is a prerequisite when learning Spring Boot. So, you should at least have some basic familiarity with the Spring Framework.
Boot is bootstrap, Spring Boot is something that let you bootstrap a spring application from the scratch, and that is how it gets its name, Spring Boot.
Here is the official definition on the spring.io website. Spring Boot makes it easy to create standalone production-grade spring-based applications that you can just run. Spring Boot makes it easy to create standalone production-grade spring-based applications. So, the key here is creating spring-based applications. Spring Boot is a tool that let you create spring-based applications. Now, what do these spring-based applications look like? What spring would create for us? It is standalone, it runs on its own its production grade. So again, it is not the hello world application you have something that you can deploy to production. And that is something that you can just run. This is especially important because if you have spent time creating a spring application without using Spring Boot, you will understand the pain of having to do a lot of stuff. There are a lot of configuration steps that you can have to do.
A lot of charges you need to import a whole lot of stuff to do, and only then do you get to a point where you run it and see it in action.
But with spring boot, that is no longer the case. You have an effortless way to create a spring application that just runs with truly little effort. So, that is the promise of Spring Boot. We will try that out and see if it really fulfills that promise.
To really get spring boot again, as I said, you need to understand spring itself. Now, what is spring?
What are the things that Spring Boot gives us...?
Spring boot is opinionated in the sense that it says well.
This is a good starting point. It makes certain configuration choices. It makes certain decisions for you.
It features the convention over configuration concept.
If you had to do 100 different things to configure something, let us say, again, let us look at the 80% use case and have that be the default only if you are of the 20% which you want things to be a little bit different, only then you configure it.
If you belong to the 80%, the majority use Case No configuration necessary, just works for the 80% use case out of the box.
The thing that Spring Boot gives you as a spring application. You can generate a spring application from Spring Boot. You can use Spring Boot to create the spring application.
If you are building a web application you would apply to a Tomcat container or some other servlet container but Spring Boot. What you get is a standalone application. What you get is something that you can just run and have it start a web server.
You do not have to find a subset container to deploy to. I'm going to talk about the difference between the two and why Spring Boot went for this approach in a little bit, but the output that you are going to get with Spring Boot.
It is just ready to run right there. You do not have to find a subset container, configure it, deploy it, and all that stuff. None of that stuff is required. Just run a command and it transit standalone application.
It is also production-ready and again I have mentioned this earlier too. You do not have to do anything extra to get it ready for production. You can just stick that and deploy it to production hubs.
What is spring...?
Now what a spring? If your answer to the question is that is something that does dependency injection, that is the perfect answer.
As of 2006, currently, that is no longer just the case. Spring is much, much more than dependency injection. It is a whole application framework. It has its origins in the concept of dependency injection.
But there is a whole lot more. It is something that lets you build enterprise Java applications.
There are like 542 enterprise Java applications out there and they all do things that are vastly different.
But the underlying concept, the underlying foundation of all those enterprise Java applications has a lot of similarities. When you are writing a business service, you do similar things for every business.
There is no matter what business problem they are trying to solve. Things like transactional services. You want to establish a transaction to connect to the database. Those are common problems. There are common things that every enterprise application needs to solve and spring handles all those things. It provides a template. It provides a framework that lets you build those enterprise applications.
It also has a programming and configuration model. The cool thing about spring is that you focus only on building your business services and you let spring handle a lot of these common concerns for things like connecting to the database, running queries, or things like handling HTTP requests, having an MVC layer, what spring lets you do is build classes and they have annotations on them which denote what they are. So, let us say you are writing a business service. You write your business service with functionality. The code contains only the logic that is specific to your business application and then what you do is annotate that business service set class with something like add service and that lets spring know that you intend that class to be a service and it applies a whole lot of things to that class, and it manages the lifecycle of the class so that it acts as a service.
So, what you do when you are building your application is focus on your business problem, and you let spring handle the rest. So, it provides that model for you to build those applications, and then it also provides infrastructure support.
Spring has support for various things. As I mentioned, again connecting to the database. If you want to connect to an admin database, you want to connect to a like a Mongo DB database.
Spring has infrastructure support for it already and you can leverage some of those infrastructure when you are building your app.
Patients, so this is spring and there are a lot of cool things about spring, but there are certain problems with it too.
The first problem is that it is a huge framework. Spring started out by trying to solve these common concerns that people could have when they are building enterprise applications
Now these common concerns are not just one thing. There are so many different things. There are so many ways in which you can build an enterprise application and spring over the years has tried to address all those diverse ways and provide support for all those.
In case you come to spring and say hey I need to build this thing with this combination. In this configuration spring says well I have a solution for you, and it has that solution in the framework.
So, over the years, there have been all these different ways of building things and spring has support for all these diverse ways and it is ended up being a huge framework in the process. There are so many things. It is at this point of time, very overwhelming to even get started like there are so many things. How do I even get started with a spring application?
There are multiple setup steps. Spring can connect to. Mongo DB can connect to RDBMS; it can connect to a whole lot of other you.
Know Jdo, which is outdated, but it still has support in the Spring Framework, so since it does a whole lot it needs a whole lot of configurations for it to do exactly what you want it to do. Since it has a lot of capabilities, you need to specify exactly what you want spring to do, so there's a lot of setup and configuration steps that you need to do with spring.
And then you have multiple builds and apply steps. You will need to know how to build and after the plug and we have various combinations. The important fundamental problem here is that.
Spring has a lot of capability. It has a lot of flexibility, and that capability and flexibility comes with a cost.
You need to do a whole lot to get it to do exactly what you want it to do, and the second thing is, since it can do a whole lot.
But you do not really have a starting point. You do not really have a guide that says, OK, this is the best practice.
This is how you should ideally do it, unless there is a need for something else, so there is no pathway for you to get to a point where you have a spring application. That is exactly what you wanted to do. You are left to figure that out on your own.
So, this is a problem that the Spring Framework has. If you were to start building a spring application, you have these problems to tackle with.
And this is where spring boot comes in handy. Wouldn't it be cool if we could somehow abstract these steps out?
Again, going back to the original premise of spring, you want to have something that is abstracting away all these infrastructure concerns. All these setup and configuration concerns so that you just focus on your business.

Comments
Post a Comment