• Spring: Please ignore my mocks

    If you are using the core Spring Framework (that is, not Spring Boot), then you may have encountered a problem where Spring doesn’t seem to completely ignore mocked beans in your tests: Perhaps Spring attempts to inject beans into them or run your @PostConstruct lifecycle methods. In this post I present that problem together with… Continue Reading

  • Spring Boot: A bit more cool with Kotlin

    In the context of my favorite framework, Spring Boot, I have recently started to explore the effect of using the Kotlin 1.1 programming language (as an alternative to Java 8). This post describes a few language features that may be interesting to a typical Java 8 developer. Also, I hope you will see that: Spring… Continue Reading

  • Spring Boot: Prometheus actuator endpoint

    In this post I show how you can add support for Prometheus in Spring Boot applications. Step 1 of 2: Add the Prometheus Spring Boot Starter You can get Prometheus support in Spring Boot applications via a so-called “starter”. Here is how to get that… It’s a one liner in Gradle: And a five liner… Continue Reading

  • Spring Boot: Controlling timezones with Hibernate

    In this post I show how you, from a Spring Boot application, can control the timezone used by Hibernate when it communicates timestamps with the database. This post is inspired by a very similar recent post by Vlad Mihalcea [1], Hibernate Developer Advocate at Redhat. It’s basically the same subject – but with a Spring Boot… Continue Reading

  • Spring: Bean qualification

    In this post I present how you can control a situation in which there are multiple beans that qualifies for an injection point in Spring. The material here has been tested with Spring Framework 4.3. The problem Let’s first take a look at the problem. Imagine you have this interface: And two different implementations of this. First this: And then this:… Continue Reading

  • Spring Boot and Gradle: Separating tests

    In this post I will present 4 different approaches to separating unit tests from integration tests, so that they can be run independently of each other. Here’s the 4 different approaches: Separation based on name patterns Separation based on JUnit categories Separation based on Spring’s @IfProfileValue Separation based on different source directories These approaches can easily be extended to apply… Continue Reading