Blog: Classier Twitter threads - Tag Java

Spring's @MockBean is an anti-pattern

I really like Spring Boot because it’s super-powerful, but like with any other power tool, you have to be careful not to lose a finger or even a whole arm.

One such tool is Spring’s @MockBean, which allows you to easily replace a service (bean) in Spring’s application context. This is really useful because having to think about all the places where a service is used and how to fully replace it in the context in order to mock it is a huge pain, and sometimes it can even be impossible.

But is it worth the price?

Continue reading ...

Consolidating logging in your Java applications

On the surface, logging in Java may appear to be standardized, but there are a few competing standards, which creates problems that we need to address. This article will look into replacing all the unwanted logging libraries with just one.

If you’re looking into how to completely and safely remove Log4j from your projects, this article shows exactly that. I’m not advocating you should do that since you might just be trading a set of known problems for some unknown ones; I’m just saying this is how you can do it if you want to.

Continue reading ...