Spring Boot: The Most Notable Features You Should Know
Let’s see what Spring Boot looks like under the hood so you can get your program up and running as soon as possible.
Join the DZone community and get the full member experience.Join For Free
What Is Spring Boot?
All in all, Spring Boot is a project built on the top of the Spring framework. It provides a simpler and faster way to set up, configure, and run both simple and web-based applications.
In the Spring core framework, you need to configure all the things for yourself. Hence, you can have a lot of configuration files, such as XML descriptors. That’s one out of the main problems that Spring Boot solves for you.
It smartly chooses your dependencies, auto-configures all the features you will want to use, and you can start your application with one click. Furthermore, it also simplifies the deployment process of your application.
It can be a bit frightening for a few of you, because it seems that there a lot of “magic” things happening in the background. Despite that, I will explain the best features of the framework. I hope you take the advantage of this additional knowledge on Spring Boot in your future projects. It really makes your life simpler.
Firstly, let’s see the notable features that make it unique and easy to use.
- Auto-configuration: It sets up your application based on the surrounding environment, as well as hints what the developers provide.
- Standalone: Literally, it's completely standalone. Hence, you don’t need to deploy your application to a web server or any special environment. Your only task is to click on the button or give out the run command, and it will start.
- Opinionated: This means that the framework chooses how to things for itself. This is the point where a lot of people says "wait a minute, I do not want to participate in it." Here I encourage you to wait for a second and hold your judgment for now, because, actually, it can be a good thing.
The intelligent auto-configuration attempts to auto-configure your application based on what dependencies you added. It is contextually aware and smart. Let’s see an example according to a database feature.
If you add a dependency to the pom.xml, which relates to a database, the framework assumes that you probably would like to use a database. Then, it auto-configures your application for database access.
Furthermore, if the dependency appears for a very specific database, for example, Oracle or MySQL. It can make a more certain assumption and probably will configure that specific database access what you exactly need.
To set up auto-configuration is extremely effortless. You only need to add the
@EnableAutoConfiguration annotation to your Spring Boot application.
That’s easy, and to remove it. So, you don’t force to use all that features if you don’t want to.
Spring Boot makes it easy to create stand-alone, production-grade, Spring-based applications that you can run.
—Spring Boot Project
You may think that running a Java application is easy — you simply give out the run command and everything works. To be honest, it is not that simple.
The Process of Starting a Java-Based Web Application
- First of all, you need to package your application.
- Choose which type of web servers you want to use and download it. They are a lot of different solutions out there.
- You need to configure that specific web server.
- After that, you must organize the deployment process and start your web server.
With Spring Boot, you need the following process:
- Package your application
- Run it with some simple command like java -jar my-application.jar
Really, it's that simple.
Spring Boot takes care of the rest by starting and configuring an embedded web server and deploys your application there.
Spring Boot takes an opinionated view of building production-ready Spring applications.
— Spring Boot project
As I mentioned before, I don’t think of it as a bad thing. If you write Java applications, you have tons of choices, starting from the web, logging, collection framework, and the build tool you use.
Despite this, in the most cases, the developers use the same most popular libraries. All that the Spring Boot does is that it loads and configures them in the most standard way. Hence, the developers don’t need to spend a lot of time to configure up the same thing over and over again.
Hence, the developers have more time for writing code and satisfying business needs.
For an example, check out the https://start.spring.io/ where you can easily select your needs and simply download the appropriate ready-to start application for yourself — with just a few clicks!
The above is a great example of how you can take the advantage of the Spring Boot opinionated setup and start your project as fast as possible.
In this article, you learned about the basic fundamentals of Spring Boot, why it is created, what are the main cornerstones of it, and what problems it solves.
The most notable features properties were:
All in all, the above serves one purpose:
To get your program up and running as quick as possible.
Published at DZone with permission of Zoltan Raffai, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.