skip to content
jgarivera.com

Learnings from my first Spring course

/ 6 min read

When I was learning Spring Boot last year, I skipped learning Spring. Yikes.

I fell into the trap of copy-pasting Spring Boot’s auto-magical annotations. Truly, it felt like voodoo magic. I just needed to depend on certain starters, know what annotations to use, and by the power of Convention over Configuration:

Voila…

It just works.1

I have a working Spring app (which I didn’t fully understand its inner workings). From what I’ve read online, I also had a grave misconception of Spring — just it being a clunkier and inferior version of Spring Boot.

Now much wiser, I was severely wrong and I’m glad to have realized it sooner.

And it turned out, skipping Spring was a big mistake on my part.

Learning better

Last January, I course-corrected my flight in how to learn Spring through a course (I’m proud of coming up with this sentence hehe).

I bought the The Confident Spring Professional course by Marco Behler. It’s one of the many recommendations I’ve found online on learning Spring. There are many good courses and books out there, but this one in particular caught my eye.

The course’s learning modules are structured in a way that would make you appreciate Spring and Spring Boot while gaining a thorough understanding of how they work and what problems they solve. Most importantly, it was concise enough for me to get valuable information from in a short amount of time.

First impressions

I started first with the course’s free available preview. It opens strongly with the complete absence of Spring Boot (and even Spring). That surprised me, because that’s what I was looking forward to.

The first module taught me how to manually start and embed a Tomcat server with plain ol’ Java servlets.

Yes, you’ve read that right. Just servlets. No fancy @Controller annotations yet.

Setting up Tomcat and fiddling with servlets are two things I thought I’d never do myself, because Spring Boot usually does them for me

From the course’s preview, I’m glad to have caught a glimpse of bare Java web development without Spring Boot. I realized there are a lot of things we take for granted when using Spring Boot.

The course also gave me a chance to work with a fresh Maven project and its different plugins (compiler, shade, etc.). I used these plugins so I could build an executable JAR that includes its required dependencies. This is also something that I had to manually configure (but indeed, Spring Boot’s Maven plugin handles this for us out-of-the-box).

I miss Spring Boot already…

From these immediate learnings, I decided to continue with the course!

How the entire course went

Each succeeding module of the course builds on top of the previous module. The sense of progression from a basic servlet app to a modern Spring Boot app was satisfying.

Here’s a summary of how one of my apps evolved with the course:

  1. It started with plain servlets, a manually embedded Tomcat server, and a poor man’s dependency injection (DI) container
  2. Then, the poor man’s DI container is replaced with Spring Context, a simple ApplicationContext, and a few bean configurations
  3. Then, servlets were replaced by Spring MVC, now having a WebApplicationContext, and more bean configurations
  4. Then, validation and Thymeleaf web pages were added to spice up the app while having even more bean configurations…
  5. Then, database connectivity using Spring JDBC (not Spring Data yet) and H2 were introduced, with a ton of bean configurations…
  6. Then, Spring Boot (finally) and several starters were added, thereby eliminating the need for a manually embedded Tomcat server and all previous manual bean configurations… This is when I had an epiphany!
  7. And in the end, I have a Spring Boot app that uses Spring Data JDBC and a custom autoconfiguration that overrides HikariCP with Vibur
My course progress
My course progress

Tada! I’ve finished the course and I had a fun time with it! :)

As you can see, I took my time in completing the course because I went thorough with studying it and doing its exercises. I believe you can complete the course in less than a week if you dedicate full-time to it.

You can access this GitHub repository to see my learning projects from the course.

This journey has ended. I’m happy the course sets me up to explore more about Spring in general. I’m even more excited now, because I have a clearer understanding of the Spring ecosystem.

My twists

During the course, I added some of my own twists to make my learning more fruitful:

  • I wondered if I could organize my Maven course projects better. So, I organized them in a multi-module project with a parent POM. This helped me centralize plugin versions and mitigate its redundant configurations.
  • I practiced testing using JUnit and Mockito. This led me to eventually use Spring Test and get exposed to its cool testing utilities like MockMvc.
  • I noticed my code formatting started getting inconsistent so I added linting using a basic Checkstyle rule.
  • Testing and linting became integral to my Maven build process and I added them to a GitHub Actions workflow.

Now what?

The learning never stops! Here’s what I plan to do next:

Revisit projects

An effective way to learn is to immediately apply what has been learned. I’ll most likely revisit past Spring Boot projects I’ve made and start from there.

Further reading

I’ll also read books about Spring. If my learning was like a movie trilogy, these would be:

The books that I'll use to continue my learning
The books that I'll use to continue my learning

The Sequel - Spring Start Here by Laurentiu Spilca

It has a reputation of being a great introductory book in Spring.

It overlaps with a lot of the topics I learned from the course I took. But, this book discusses those topics with a lot more depth. There are also new topics, such as Spring AOP and a dedicated section on testing Spring apps, which excites me!

I’d like to achieve good fundamentals first. After that, I’ll move on to the other Spring books by Manning, particularly the “In Action” series.

The Prequel - J2EE Design and Development by Rod Johnson

I’ve encountered this book recommendation from the Pinoy Java User Group (JUG) Facebook group. I’m forever grateful for the insights shared there.

The ideas of Johnson’s book laid the foundation to the Spring framework we know today. I’m curious to learn more about the history of Spring and what was early J2EE development like.

I expect to encounter many outdated ideas from this book since it was released in 2002. Nevertheless, I’m still looking forward to read this one. I’m especially curious to know which of its ideas are still practical and relevant today.

Footnotes

  1. This a meme phrase that stuck with me. It’s tend to be used when you can’t explain how something works.

The discussion for this post can be found here as well.