Home » Archives for Daniel Olszewski

Author Archives: Daniel Olszewski

Daniel Olszewski is a software developer passionate about the JVM ecosystem and web development. He is an advocate of clean, maintainable, and well tested code

Running code on Spring Boot startup

spring-interview-questions-answers

Spring Boot does a lot of configuration automatically for us but sooner or later you’ll have to do some custom work. In this post, you will learn how to hook into the application bootstrap lifecycle and execute code on Spring Boot startup. So let’s see what the framework has to offer. 1. Execute method on bean initialization The simplest way ...

Read More »

Java optional parameters

When you design a method in a Java class, some parameters may be optional for its execution. No matter it is inside a DTO, a fat model domain object, or a simple stateless service class, optional method parameters are common. From this article you will learn how to handle optional parameters in Java. We’ll focus on regular method, class constructors ...

Read More »

HTTP cache with Spring examples

spring-interview-questions-answers

Caching is a powerful feature of the HTTP protocol but for some reason, it’s mainly considered for static resources like images, CSS stylesheets, or JavaScript files. However, HTTP caching isn’t limited to application’s assets as you can also use it for dynamically computed resources. With a small amount of work, you can speed up your application and improve the overall ...

Read More »

@ParameterizedTest with null values in @CvsSource

Writing parameterized tests in JUnit 4 was pretty cumbersome. JUnit 5 introduced several useful improvements to the framework and running the same test with different arguments is much simpler than in the previous version. However, there is one small issue with passing null values in such arguments. In this post, I’m going to show you how to pass null in ...

Read More »

How to bind @RequestParam to object in Spring

spring-interview-questions-answers

Do you have multiple parameters annotated with @RequestParam in a request mapping method and feel it isn’t readable? The annotation looks pretty straightforward when there’s one or two input parameters expected in a request but when the list gets longer you might feel overwhelmed. You cannot use the @RequestParam annotation inside objects but it doesn’t mean you’re left with no ...

Read More »

Feature toggle in Spring Boot 2

spring-interview-questions-answers

Whether you like it or not, software development is a collaborative activity. Integration work has always been demonized and treated as necessary evil. There are several approaches which try to solve the challenge of effective integration. The feature toggle belongs to that group. In this article, you’ll see in practice how feature toggles, also known as feature flags, can be ...

Read More »

Spring @Lazy annotation use cases

spring-interview-questions-answers

The Spring framework with almost no effort can solve for you many common programming problems, but some of its features are less known than others. In this post, we’re going to take a close look at the @Lazy annotation, which belongs to this group. After reading several examples, you should be able to apply the annotation to your daily development ...

Read More »

Why developers don’t use TDD

Although the total number of acronyms in the programing industry has probably already exceeded the number of stars observable on the moonless night sky, only a subset has gained popularity and recognition. TDD definitely belongs to this group. Judging by numerous conference lectures, books, podcasts, and blog posts, the fact that Test Driven Development is a widely known technique is ...

Read More »

Spring Cloud – Basic setup

spring-interview-questions-answers

Spring Cloud solves common problems of distributed systems. However, for someone who works only with widely known monolith applications jumping into the long list of patterns designed for distributed services might be quite overwhelming at the very beginning. This article will take you through the basics of Spring Cloud by taking a practical approach. After finishing, not only you should ...

Read More »