My learning diary

My first yarn package

I wrote my first yarn package (kind of for fun) yesterday. It’s strange how I’ve been consuming packages but never went to the other side of the table: Writing a package. As of now, I haven’t published my package, but I’m omw. So, how did I create a package? It just felt like the usual… I followed the yarn docs. One difference (compared to my usual activities) was I couldn’t do import { .

Continue reading "My first yarn package"

Almost done with the custom starter

I was right. I forgot to enable the Mongo repository. And it wasn’t only that. I had two Mongo configuration classes. One in the consumer and another in the custom starter. I needed only one. I removed the configuration class from the custom starter. Then, I enabled the custom starter’s repository in the consumer’s configuration class. Below is an idea of how my configuration class looks like: @EnableMongoRepositories(basePackages = { "yourTLD.

Continue reading "Almost done with the custom starter"

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"