Today’s the last day of Spring One in Santa Clara, California, the biggest conference on the Spring eco system, and it’s time for a wrap-up. There have been a lot of sessions, and of course it’s not possible to cover them all. I’ll do two blog posts, one focusing on batch, and one focusing on the general stuff that probably will make a difference in the future. This is the one on the general stuff, covering Spring IO and Spring Boot.
The Spring IO platform is a new presentation of all technologies and projects living under the Spring umbrella. It basically splits them up into two groups: IO Foundation and IO Execution . IO Foundation contains all the different Spring projects you know, and IO Execution contains projects using those foundational libraries, combining them. Two of those IO Execution projects are Spring Boot and Spring XD, the first I’ll cover in this post, the second in the next post.
With Spring IO there comes a brand new website , what’s exciting about that? Two things:
- It’s built 100% on Spring, and it will be open source soon. A reference application in production.
- It provides a much better starting point to get to know Spring than it did before. Take a look at the guides : focusing on solving a task rather than on certain Spring projects.
Spring is around for ages now, and so are blog posts covering building something with Spring. Since the Spring website didn’t provide a good starting point for solving problems, you typically googled for a solution on the web. You find something, include it in your project, and hopefully it works. But has it been the easiest way? The most up to date way? It’s likely that it hasn’t. With the Getting-started-guides and the tutorials, the Spring guys now not only present all the possibilities you have in the reference documentation, but they also present the state-of-the-art way of doing something. It’s opinionated, and it’s perfectly fine to have another opinion, but at least it’s there, and you can make up your mind about it.
If you looked into some of the guides, you might have noticed that most of them indicate they are “using Spring Boot”. So what it is? When Spring in the past was really good in eliminating boiler-plate code, it wasn’t that good in reducing boiler-plate configuration. Spring Boot aims to change that. It sits on top of the other Spring projects. The following section is taken from the Spring Boot starting guide , and it pretty much wraps up what Spring Boot is about:
Spring Boot offers a fast way to build applications. It looks at your classpath and at beans you have configured, makes reasonable assumptions about what you’re missing, and adds it. With Spring Boot you can focus more on business features and less on infrastructure.
- Got Spring MVC? There are several specific beans you almost always need, and Spring Boot adds them automatically. A Spring MVC app also needs a servlet container, so Spring Boot automatically configures embedded Tomcat.
- Got Jetty? If so, you probably do NOT want Tomcat, but instead embedded Jetty. Spring Boot handles that for you.
- Got Thymeleaf? There are a few beans that must always be added to your application context; Spring Boot adds them for you.
These are just a few examples of the automatic configuration Spring Boot provides. At the same time, Spring Boot doesn’t get in your way. For example, if Thymeleaf is on your path, Spring Boot adds a SpringTemplateEngine to your application context automatically. But if you define your own SpringTemplateEngine with your own settings, then Spring Boot won’t add one. This leaves you in control with little effort on your part.
And then one more important note:
Note: Spring Boot doesn’t generate code or make edits to your files. Instead, when you start up your application, Spring Boot dynamically wires up beans and settings and applies them to your application context.
Building applications with Spring Boot is really fast, especially for web applications. No need for downloading and installing a servlet container, no need for doing anything but writing controllers (and view templates, if it’s not a rest service), and you get an executable jar running your web app (see this guide ). If you don’t want to have an executable jar file you can still create a classic war file deployable on any servlet container.
A very interesting add-on is the Spring Boot Actuator you can easily pull in . Just by adding the dependency you automatically get management endpoints (on a different port) that allow valuable insights into the application. There is the simple
/health endpoint returning 200 and
ok in the body when everything is okay, there is the
/metrics endpoint returning counters and average values for requests, memory consumption etc. by default but is fully configurable, and there are more endpoints like
/dump for thread dumps and
/trace for log files. All of this set up just by adding a dependency! And still fully configurable.
And then, by adding Spring Security to the classpath, everything is secured by default, and you just have to add an AuthenticationManager bean to let the application know how to authenticate the users.
It will be very interesting to see how it works out in the enterprise, because of course it adds a little bit more magic to it, but that’s how it is: either you do everything by yourself, know exactly what happens and need hours or days for stuff that doesn’t have to do with your business, or you accept a little bit of well-documented magic and concentrate on the business part.
Spring Boot is not GA by now, but Spring IO is already built on it, so they have a really good test suite.
Spring Boot is still work in progress, but it seems to be very promising. It’s important to know that it’s not another project among the other Spring projects, but sits on top of them and will be the recommended way of building Spring applications in the future. For all kind of Spring applications. And Spring IO, the new website, is definitely a step forward.
By the way, Dave Syer, former project lead of Spring Batch and current Spring Boot project lead, said on his keynote that he hasn’t been using XML for six months now and he’s not missing it. And he used to be one of the biggest supporters of the XML configuration style.