Spring Boot is one of the latests projects of the Spring galaxy. I discovered at the Bordeaux JUG during a session by Sébastien Deleuze. The main features are: creation of standalone applications, simplified configuration and fast startup but there is more.
YASP!
Everybody knows Spring, many had work with Spring, for some if was good, for others less good. I wrote Spring galaxy above and that might be a valid metaphor. Sometime I feel that taking a trendy technical word and prefixing it with Spring gives an actual Spring project. Let’s try:
- framework easy: Spring Framework
- social media almost: Spring Social
- data: Spring Data
- cloud: Spring Cloud
- docker: ok nothing for this one but as we will see it might not be needed with Spring Boot.
So do we need Yet Another Spring Project?
Hello World!
So to give a try to Spring Boot I decided to follow the tutorial. In order to have a rest service replying Hellow World! we only need two files: a Java file and a pom.xml
(the use of gradle is also supported and described in the documentation).
The Java file is pretty short actually 5 lines of code or annotation, not so bad:
For the build we are a tiny pom.xml
with one parent, one dependency and one plugin:
Keep in mind that we still have Spring MVC underneath and to measure the feat that is done by Spring Boot, have a look here or there to see how a Spring MVC Hello World tutorial looks like.
To run the project you only need to have Java installed:
Conclusion
Writing a Hello World! following the documentation is hardly testing a framework. But, for what I saw, I really have the impression that Spring Boot is a big step in the right direction: self contained executable jars out of the box, a very effective simplification either on the code or the build, and some nice features related to configuration, monitoring (easy integration of CRaSH).
Docker
I spoke about Docker earlier telling that there is not need for a Spring-Docker project and it is not really needed since a Dockerfile
would be something like: