For me, it could be difficult to imagine the inception of a medium / big Java project without using Spring framework. There is a myriad of reasons for that. It makes the code base clean and loosely coupled. The whole plethora of abstractions provided by Spring makes the life easier when dealing with JDBC, JMS, NoSQL datastores, transaction management, AOP programming, etc. It's modular, lightweight, opensource and has a vibrant community. It can order you a pizza. Not actually, but however, it's de facto J2EE framework (anybody heard about Seam?).
I have been using Spring for almost seven years and had followed it's evolution, the born of new subprojects and the overall expansion of the Spring ecosystem. Spring had been often criticized for being a XML metadata configuration oriented framework. Then, Spring JavaConfig has appeared. Its goal was to focus on a Java centric Spring configuration through different annotations like
@Bean and the
AnnotationConfigApplicationContext implementation. Spring JavaConfig was a trampoline for what now is known as Spring Boot.
Spring Boot provides an abstraction layer on top of Spring core and the rest of subprojects under the Spring umbrella, with no need to deal with XML configuration files, the pattern known as CoC (Convention Over Configuration). In this post I would like to expose the pros and cons of Spring Boot.
NOTE: These are my very personal and humble opinions whose might not be coherent, and off course, it doesn't mean you have to agree with them.
- Quick up and running of the standalone and containerless Spring applications. You just assemble the jar artifact which comes with an embedded Tomact, Jetty or Undertow application server and you are ready to go.
- Simplified dependency management through the starter POMs.
- Visibility into your application internals. Spring Boot provides the HTTP endpoints to get detailed metrics about the application inner working, health status, etc. SSH shell and the jtop are really awesome.
- For the Java purists and the haters of XML configuration files, the good news is there are no XML at all. The beans are initialized, configured and wired automagically.
- The Spring Initializr provides a project generator to make you productive with the certain technology stack from the beginning. You can create a skeleton project with web, data access (relational and NoSQL datastores), cloud, or messaging support.
- If you are new to Spring and want to learn how the dependency injection, AOP programming, and proxies work, starting with Spring Boot is not a good choice. Spring Boot hides the most of these details from you.
- I find the Java Config programming model is more intrusive with your application code base. If the IoC principle is about delegating the lifecycle and the instantiation of the classes to external entity (the container), then, the principle is being violated. It’s the programmer itself who is responsible for creating the required beans. Moreover, if the implementation of your class changes, you are forced to change it in your code. With XML oriented programming model it would be enough to update the bean definition. The introduction of Spring XML namespaces had greatly simplified the configuration files, so there is one less reason to hate them.
- If you are a control freak, I doubt Spring Boot would fit your needs.
- Spring Boot sticks good with microservices. The Spring Boot artifacts can be deployed directly into Docker containers. In a large and monolithic based applications, I wouldn’t encourage you to use Spring Boot.
- If you are not familiarized with other projects of the Spring ecosystem (Spring Integration, Spring AMQP, Spring Security, etc), using them from Spring Boot will make you miss a lot of concepts, which by the other hand you would acquire if you had started using them independently.
Seven years ago, Spring framework had changed my perception on software development. Nowdays, it’s being the essential part of my day to day programmer’s life. I still feel very comfortable with XML based configuration, or the hybrid combination of JavaConfig and XML. That doesn’t mean things won’t change, and make the tip to scales in favor of Spring Boot.