Generating HTTP clients in Spring Boot application from OpenAPI spec| maciejwalkowiak.com
TIP Projection is a subset of an aggregate loaded from a repository for read-only purposes. Methods returning projections are typically defined on the repository level, making the repository interface aware of all possible types of projections used in the application. javapackagecom.app.account.domain;publicinterfaceAccountRepositoryextendsRepository<Account,String>{AccountBasic findAccountBasicById(Stringid);AccountComplete findAccountCompleteById(Stringid);}publicrecordAccountBasic(String i...| Maciej Walkowiak - Java & Spring
In this article you will learn how to enable container debug logs with Testcontainers and Spring Boot and how to leverage Spring Framework flexibility to turn logs on and off with a custom @EnableContainerLogs annotation. As a side effect you'll learn a little about Spring Framework internals enabling Spring's magic ✨.| Maciej Walkowiak - Java & Spring
A common pattern in Java, whenever there is a need retrieve data from a database or deserialize JSON is to pass the target object class as a parameter. A good example is Jackson's ObjectMapper#readValue method with following signature: javapublic<T>TreadValue(String content,Class<T> valueType) {...} Passing class as a parameter looks repetitive. Since <T> defines the type, why do we need to pass Class<T>? Why it can't be simplified to: javapublic<T>TreadValue(String content) {...} And most im...| Maciej Walkowiak - Java & Spring
INFO Advice given in this article is especially relevant to applications with hundreds of Flyway migration files. In Spring Boot & Flyway - clear database between integration tests I described how to ensure that each integration test starts with clean state - wipe out content from the database, and all database migrations applied from scratch. Such approach simplifies writing tests but comes with one significant drawback - running database migration takes time. The more migration files, the l...| Maciej Walkowiak - Java & Spring
Scheduling jobs with Quartz has been discussed numerous times. However, it is worth to know that Quartz can be used not just to run jobs every X hours or based on a CRON expression, but also to execute specific code once at a specified time in the future. I believe that in some specific use cases, following this approach can dramatically simplify your architecture and implementation. Let's see step by step how to do it.| Maciej Walkowiak - Java & Spring
"How to set up Testcontainers with Spring Boot" has already been described hundreds times. I am not going to write the same things that have already been said but rather discuss the pros and cons of the existing solutions and present one that works for me and I believe works for majority of projects. Specifically, I am looking for a solution that meets following criteria: as little overhead as possiblecontainers are started only once for all tests containers are started in parallel no require...| Maciej Walkowiak - Java & Spring
To make sure that tests are repeatable and isolated, it is a good practice to ensure that they always start with a clean state. In unit testing this could be mocking dependencies, or setting certain properties on objects. In integration testing it often means bringing the database to a well known state - usually erasing all the tables, and inserting the data that the integration tests expect. In this short tutorial you'll see how to clean a database between integration tests. The recipe assum...| Maciej Walkowiak - Java & Spring
If you feel a little overwhelmed with the constant stream of news from the Spring team - I hear you. November was a very hot month for Spring developers. In addition to plenty of Spring project portfolio releases there were few interesting changes that you might have missed. Below I collected the most important things (and added some notes) that I believe you - as a Spring developer - should know to stay up to date.| Maciej Walkowiak - Java & Spring
In rare cases, project build may require different configuration depending on operating system that runs the build. In Maven, it can be done with Maven Profiles. how to configure profiles per operating system the trick to activate profile on Linux but not on Mac how to enforce presence of active profile with maven-enforcer-plugin how to run build on different operating systems with GitHub action| Maciej Walkowiak - Java & Spring
| Maciej Walkowiak - Java & Spring
Can you create a new Java project from scratch, manually, without copy & pasting? I don't. And probably you shouldn't as this is a pure waste of time considering how repetitive the base code and the directory structure is.| Maciej Walkowiak - Java & Spring
PostgreSQL and UUID as primary key| maciejwalkowiak.com