Spring Pet Clinic: Things I Still Don't Understand
There are still a lot of things I don't fully understand about how a Spring Boot web application really works.

I picked up the Spring Pet Clinic project again, and I'm considering it done (for now). My documentary professor in college used to say that "films aren't finished, they're abandoned", because you can keep working on a personal project endlessly and never "finish" unless you make yourself stop. I have an implementation that has a working happy path, a number of GET routes and two POST routes, and I'm coming out of it a little more knowledgeable about Spring than I went in.
That said, there are still a lot of things I don't fully understand about how a Spring Boot web application really works. It's all still a bit too much magic. I want to make a list of these magical things, so that I can dig into them in the future.
@Autowired
@Autowired
has become a little less mystical. By this, I mean that I have a clearer idea of when and how to use @Autowired
, but I still don't think I have a good mental model of what it is doing under the hood.
One thing that I would like to do is to take a small autowired codebase with good test coverage, and rewrite the code without @Autowired
, then autowire it back up.
Json serialisation and deserialisation
I think in my Spring Pet Clinic application, I serialise my Java objects three different ways: relying on Jackson's serialisation of my JPA entities, creating a POJO to serve as a JSON view for an entity and letting Jackson serialise the POJO, and lastly, creating custom serialisers for specific attributes, when I didn't know better. In retrospect, I think custom serialisers were unnecessary for my use case.
It took me a while to understand how exactly Jackson is performing the (de)serialisation: through the use of getters and setters (at least for private properties). There's a whole host of Jackson annotations like @JsonProperty
, @JsonGetter
, @JsonSerialize
, @JsonIgnore
, etc. but at the moment I don't think I have a clear idea how to use them and how they relate to (de)serialisation using getters and setters.. Right now, my JSON views, and the JSON objects that my Pet Clinic application can accept, are not very configurable.
Testing
My tests are a mess. I don't have a good handle on how to write unit tests for controllers in Spring Boot, especially when I don't have a clear understanding of how (de)serialisation works yet.
Hibernate and Spring Data JPA
This one is the easiest to get my head around, I think, because they are analogous to ActiveRecord in Rails. I don't think a lack of understanding is the issue here. It's more of learning the full power of what Hibernate and Spring Data JPA can do, understanding how to build complex relationships with Hibernate and the full power of the JpaRepository
interface.
Next Steps
I'm going to step away from this project for a while and do something else, but I also think I need to take some time and review some Spring Framework Guru material. Hopefully, by alternating periods of theory and practice, I can start to build up that mental model of Spring that I need.