In this post, you’ll learn how the magic, or better said the auto-configuration, works in Spring Boot. To do so, you’ll analyze how a basic Spring Boot app works to see how you get an embedded Tomcat web server in an example codebase available on Github.
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.
This guide shows you how to implement custom error handling in Spring Boot. We use not only the well-known ControllerAdvice and ExceptionHandler annotations but also DefaultErrorAttributes and ErrorController to make your custom error attributes uniform and consistent.
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.
This blog post shows you 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.
This sample application also demonstrates how to use multiple Kafka consumers within the same consumer group with the @KafkaListener annotation, so the messages are load-balanced. 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.
This is a short guide on how to deploy a Spring boot war packaged application to Wildfly and Tomcat. As you know, Wildfly is the name of the community version of JBoss EAP, so this configuration should work for JBoss EAP as well.
This guide contains examples that show you how to serialize and deserialize from Java to JSON. It covers the basics and the most common use cases: Strings, Objects, Dates, Optionals, Lists, Maps, etc.
In this post, I’ll show you how to write more readable Unit Tests using a Behavior-Driven Development style (BDD). This is a coding style that is very easy to adopt and, at the same time, brings a huge benefit: it increases your test readability (a lot). Besides, it’s a small change that may drive you to go full-BDD (i.e. writing your test scenarios before your code).
With a practical example, you’ll see how to make this change with two very popular libraries: Mockito (and its BDDMockito implementation) and AssertJ.
Microservices are not always the solution
We, as developers, make mistakes. For example, one of the most common ones is thinking that a new technical solution or paradigm will solve all the problems existing in a given Software Project. That won’t happen, but we’ll be tempted anyway to fall into this trap. Microservices Architecture is one of the most popular traps.
Cucumber is a great framework to create tests using a BDD approach. Unfortunately, the official website doesn’t provide too much documentation, so it might be tricky to set it up. In this post, I’ll show you how to combine Cucumber with Spring Boot using the cucumber-spring
library to leverage Dependency Injection.