6 Simple Reasons Why Spring Boot Rocks
6 Simple Reasons Why Spring Boot Rocks
Many people have heard and seen a lot of buzz about Spring Boot, but I talk to many people all the time who have no idea what Spring Boot even is, and more importantly, what is so great about it.
Spring Boot is a section of the Spring Framework that is dedicated to making Spring super easy to use. The most significant piece of this is that there is:
No Separate Web Server Needed
Which means that you no longer have to boot up Tomcat, Glassfish, or anything else. You can literally run your web application withjava -jar myWebApplicaiton.jar
. The Spring team have managed to do this by creating annotations that you can put on your main()
class file to tell Spring just what you are looking to build.
This is a massive improvement, that filters down into a vast number of areas.
Better Debugging in IDEs
For those of use who use InteliJ IDE, NetBeans IDE, or most other mainstream IDEs, Spring Boot rocks because you can run your application using the IDEs debugger tools directly with your code, you no longer have to debug the whole web server.
Faster Deployment
Because you do not have to wait for Tomcat or Glassfish to boot up, and then find your application and then finally run, because everything is bundled together, the boot up time is cut in half.
Everything Simplified So You Can Get Running With 1 File
This is the crazy part, with Spring Boot, you no longer have to haveweb.xml
, a configuration class, security classes, and all the rest, you can literally get Hello World running with one java file (and a pom.xml, or build.gradle):
…and there you have a web application. What dependencies do you need? Just 1 dependency, and you have everything you need:
Ready to make it a web applicaiton? Just add a controller:
As you can see, the Spring team has made it extraordinarily easy to get rolling and thus…
Spend Less Time with Configuration
Since there is no web.xml
file, how do you define beans, and how do you configure the application? The answer is remarkably simple, and programmer friendly; simply add classes annotated with@Configuration
and then you can add methods annotated with@Bean
, and Spring will automagically load up the object and manage it like it always has. You can even add @Autowired
to the bean method to have Spring autowire in dependencies needed for the bean.
Application Properties
But what about application properties? This is the really fun part; just addapplicaiton.properties
to src/main/resources
and spring will automagically load up that file and can be used throughout the applicaiton through a number of ways, but can be autopopulated by spring like so:
Customize Spring Boot
Better yet, all of spring boot's automagicalness is based off of these properties, and the Spring team has provided a complete list of the default properties that are used, and thus how they can be overwritten here: http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html.
Environment Based Configuration
Using these properties, you can pass into the application which environment you are using with:-Dspring.profiles.active={enviornment}
. Spring will then load up the subsequent application properties file at (application-{enviornment}.properties
) after loading up the main application properties file.
There is SO much I could write about this, but suffice to say it's worth investigating.
No More XML
At long last, we can finally say that we are a XML free people. I now no longer have to look at XML name-spaces, proper usage, of any of the other terrible things that go along with XML, especially if you use Gradle.
All in all, Spring Boot will save you time. It's inherent speed due to its light weight, and ability to rapidly develop make Spring Boot a top pick for me when starting or cleaning up any Spring project.