⚠️ 2025-01-19: A comment about this page. Consider the below posts an ARCHIVE of my software engineering blog posts. It has been years since I last wrote about software engineering. You know ... life happens. I am still a software engineer, but I have not been having the time to keep writing about it. I hope to get back to it one day.
Here’s how you can host multiple Web sites with custom domain names from a single S3 bucket using a single CloudFront distribution. For example: x.foo.com > My CloudFront Distribution > s3://my-bucket/x.foo.com y.foo.com > My Cloud...
Hello World. This is the first post since I decided to cancel my Wordpress blog. This new blog solution is hosted on GitHub and generated with Jekyll. I hope that I get the time to import my old blog posts over the next weeks.
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...
In this post I am going to show how to copy MDC data from Web threads to @Async threads using a brand new Spring Framework 4.3 feature: ThreadPoolTaskExecutor#setTaskDecorator() [set-task-decorator]. This is the end result: Notice the third an...
In this post I am going to look into Kotlin properties [1] from a Java developers perspective. By a few examples and by looking into the generated code. I have created an example project on GitHub. You will find a few examples of how to declare p...
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 ...
Are you a savvy Java EE 7 application developer? My bet is then, that you are using Java 7/8 for developing your favorite components (EJBs, CDI beans etc). In this post I am going to show how you can develop a Java EE 7 application using Kotlin 1....
In this post I show how you can create a Spring Boot 1.5 application using Kotlin 1.1 (as opposed to typically Java 8 in these times). The example I’ve created is a typical “Hello World” example. I have chosen to implement a Spring MVC controller...
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 t...
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 Develope...
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 pro...
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...
In this post I show how you can implement Gherkin tests for Spring Boot 1.4.1. Here is an example of a Gherkin based test script: The Feature, Scenario, Scenario Outline, Given, When, Then and And constructs are part of the Gherkin test languag...
In this post I will show you how to bend the Spring Framework a little bit. In particular I will show you how you can make code like this: 1 2 3 4 5 6 7 8 9 10 11 @BusinessService public class GreeterService { @LocalizedMessage("greeterservice...
Did you know that Spring Framework 4.3 comes with a ”hidden” gem: the InjectionPoint class? At the time of writing this post, InjectionPoint is nowhere to be found in the Spring Framework Reference Documentation [2]. About the InjectionPoint cla...
In this post I show how you can declare loggers like this: 1 2 3 public class MyService { private static final Logger LOG = MyLoggerFactory.getLogger(); } There is no argument to the MyLoggerFactory::getLogger method. Contrast that to the n...
In this post I show how you for a single Web request can make your Spring Boot application dump all log statements on all categories (TRACE, DEBUG, INFO, WARN, ERROR). Everything - but only for the specific Web request that you care about. I show ...
This post shows how you can implement a custom Spring Boot Actuator endpoint that prints information about all active HttpSessions: HttpSession meta data is prefixed with @ signs: id, creation time and last accessed time. The other values are a...
In this post I show how you can develop custom Spring Boot Actuator HTTP endpoints for obtaining detailed insight into your Spring Boot application’s runtime behavior. Here’s an example: The above output is simple. Yet it can be useful to have...
In this post I show how you can add extra information to your applications’ thread dumps. I will use Spring Boot as an example environment - but the idea is very generic: You can, for example, easily apply this technique to any other Java EE appl...
In this post I show how you can tune your Spring Boot application’s logging output - such that it has even more information when you need to troubleshoot. The method is actually so generic that you can apply it to other types of Java applications ...
Custom auto-configuration JAR: A shared JAR module containing Spring beans that can be automatically activated in one or more Spring Boot applications. Auto-configuration JARs are extensively used by the official Spring Boot starter modules you a...
I am really happy with the actuator functionality in Spring Boot applications. It offers some fantastic tools for gaining insight into your application. Some of the REST endpoints that you get - such as health and metrics - are easy to read. Despi...
This post describes a technique that my previous colleagues and I successfully used for integration testing a large and complex legacy Java EE 7 application (EAR file). The tests were successfully implemented using Arquillian along with a few Wild...
Spring 5 is going to include support for the reactive programming model [1]. Here’s an example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import org.springframework.http.MediaType; import org.springframework.http.client.reactive.R...