DEV Community

Cover image for ๐Ÿš€ Building Spring by Example: Completing the Advanced Spring Module
Mujuzi Moses ๏ฃฟ
Mujuzi Moses ๏ฃฟ

Posted on

๐Ÿš€ Building Spring by Example: Completing the Advanced Spring Module

When I started learning Spring, I noticed something about many of the tutorials I found.

They often showed how to use a feature, but not always why it worked or when you should choose one approach over another.

I learn best by building things and documenting what I discover, so I started a project called spring-by-example.

The idea is simple: instead of building one large application, Iโ€™m creating a collection of small, focused examples where each example explores a specific Spring concept with clear explanations, tests, and documentation.

Iโ€™m happy to say that Iโ€™ve now completed Module 12 - Advanced Spring. ๐ŸŽ‰

This module was a particularly interesting one because it moved beyond the higher-level features I had been using and gave me a closer look at some of the abstractions and extension points that make Spring work.

The module covers:

  • BeanFactory
  • ApplicationContext
  • FactoryBean
  • BeanDefinition
  • BeanDefinitionRegistry
  • ImportSelector
  • DeferredImportSelector
  • ImportBeanDefinitionRegistrar
  • Environment
  • Property Sources
  • Resource Loading
  • MessageSource
  • ConversionService
  • Validation
  • Spring Expression Language (SpEL)
  • Method Injection
  • @Lookup

One of the things I really enjoyed about this module was seeing how much of Spring's behavior is built around the application context, bean definitions, and the container itself.

For example, BeanDefinition helped me understand that Spring doesn't immediately need an object instance to know how a bean should be created. Instead, it can work with metadata describing the bean.

BeanDefinitionRegistry then showed how those definitions can be registered and managed programmatically.

The configuration-related examples went even deeper. With ImportSelector, DeferredImportSelector, and ImportBeanDefinitionRegistrar, I explored different ways Spring can dynamically select configuration or register bean definitions during application context processing.

I also explored the Environment and property sources, which helped connect Spring's environment abstraction with how configuration values can be provided and resolved from different sources.

The Resource abstraction and MessageSource introduced another side of Spring: providing consistent APIs for accessing resources and resolving localized messages.

With ConversionService and Spring validation, I explored how Spring provides reusable infrastructure for type conversion and object validation rather than requiring every application to implement these concerns independently.

Then came SpEL - Spring Expression Language - which was a great example of how Spring provides its own expression engine for evaluating values, properties, variables, and expressions.

Finally, I explored Method Injection and @Lookup, including the interesting singleton/prototype problem where a singleton bean needs to obtain a new prototype instance whenever a method is called.

What made this module especially meaningful is that it wasn't just about learning more Spring APIs. It gave me a better understanding of the machinery underneath the features I've already been using.

And there's another milestone worth mentioning: SpEL was my 100th example in the project. ๐ŸŽ‰

After building examples across Spring Core, dependency injection, bean lifecycle, events, AOP, transactions, Spring Boot, Spring MVC, testing, and now Advanced Spring, reaching 100 examples feels like a significant milestone in this learning journey.

The goal still isn't to simply collect Spring annotations and interfaces.

I'm trying to understand how Spring works, why these features exist, and how the different pieces of the framework fit together - one focused example at a time.

The project is open source, and Iโ€™m continuing to build it as I learn:

๐Ÿ”— GitLab: https://gitl.ab/gfDEyGH3

๐Ÿ”— GitHub: https://gith.ub/dsAQrAU5

Thereโ€™s still a long way to go, but completing Module 12 - Advanced Spring and reaching 100 examples feels like a milestone worth celebrating. ๐Ÿš€

Next up: continuing with the next stage of the project and exploring more Spring concepts, one example at a time.

If youโ€™ve worked with Spring before, whatโ€™s one advanced Spring concept you think developers should understand better?

java #springframework #opensource #github #learninginpublic #backend #softwareengineering #spring #springboot #programming

Top comments (0)