My learning diary

Auto-configuring controllers and repositories

I auto-configured Spring Boot REST controllers by adding their names to the spring.factories file. On the other hand, I did not have much luck with auto-configuring Mongo collections (yet). I then ran the consumer’s codebase and used Postman to hit the newly-offered endpoints. Below is the response seen in Postman: { "error": { "IllegalArgumentException": "Couldn't find PersistentEntity for type class yourTLD.yourOrg.yourProject.somePackage.SomeModel!" } } I thought the Mongo repository was not auto-configured, so I went to check the consumer’s logs.

Continue reading "Auto-configuring controllers and repositories"

Spring Boot Auto-configuration

Every time I use Spring Security, I have to copy and paste a lot of boilerplate code. What if I made the boilerplate code configurable? I decided to venture into this idea. At first, I extracted only the method body which configures HttpSecurity. So I got myself something like a utility library. But this meant there was still some boilerplate code outside of the library. This approach required consumers to define their own configuration classes (annotated with @Configuration).

Continue reading "Spring Boot Auto-configuration"