How Spring Boot auto-configuration works

How Spring Boot auto-configuration works

In this post, we’ll create a basic Spring Boot application that includes the Web dependency. Then, we’ll analyze it to see how we got an embedded Tomcat web server in our application. This way, we’ll get to know how the magic, or better the auto-configuration, works in Spring Boot.

read more

Shebang script files with Java and Docker

Shebang script files with Java and Docker

The implementation of the JEP 330: Launch Single-File Source-Code Programs available from Java 11 allows us to write a script in Java and run it as a shebang file. This is very useful for developers like me, who are not very familiar with scripting with other languages like bash or python.

In this post, I’ll show you how to write a single-file script in Java and run it from the command line. As an extra topic, you’ll learn how to put this file in a Docker image for even easier distribution of your script.

read more

Java 12’s Switch Expressions in 5 minutes

Java 12’s Switch Expressions in 5 minutes

The version 12 of Java comes with a new preview feature (amongst others): Switch Expressions. Let’s see how this feature can simplify some of our daily tasks.

Java 12 Switch Expressions
Java 12 Switch Expressions

read more

Spring Boot and Kafka – Practical Configuration Examples

Spring Boot and Kafka – Practical Configuration Examples

This blog post shows how to configure Spring Kafka and Spring Boot to send messages using JSON and receive them in multiple formats: JSON, plain Strings or byte arrays. Based on this configuration, you could also switch your Kafka producer from sending JSON to other serialization methods.

This sample application also demonstrates the usage of three Kafka consumers within the same consumer group, so the messages are load-balanced between the three. Each consumer implements a different deserialization approach.

Besides, at the end of this post, you will find some practical exercises in case you want to grasp some Kafka concepts like the Consumer Group and Topic partitions.

read more