Skip to main content

Spring

Automating javax → jakarta and Boot 3 → 4 Upgrades with OpenRewrite

Every Spring team eventually faces the same afternoon: change javax. to jakarta. in four hundred files, rewrite the security configuration, rename a dozen properties, and then do it again for the next major version. It is dull, error-prone work, and it is exactly what a tool called OpenRewrite is for. OpenRewrite reads your source into a tree, applies recipes — small, named, repeatable edits — and writes the result back, formatting intact. You run it as a Maven plugin. This article runs it for real on a deliberately old application, shows every line it changed, and, more usefully, lists what it left for you. You need to know what Maven is and what a Spring Boot upgrade involves; nothing about OpenRewrite. Versions and status. rewrite-maven-plugin 6.46.1, rewrite-spring 6.37.1, rewrite-migrate-java 3.42.1. Legacy app: Spring Boot 2.7.18 on JDK 17.0.20, Maven 3.9. Recipes moved it to Boot 3.5.16 and then 4.0.8; I bumped the last step to 4.1.1 by hand. One legacy application with one test is a demonstration, not a survey — your codebase will find things this one does not. Companion code: spring-boot-demo/openrewrite.

Multiple DataSources in Spring Boot 4 with Spring Data JPA

Two databases in one Spring Boot 4.1 application: a DataSource, Flyway, EntityManagerFactory and transaction manager per database, package-based repository scanning, and every way it fails, each run and quoted from a committed transcript.

Spring Application Events: @EventListener, @TransactionalEventListener and Async Events

Spring events are blocking method calls, and that one fact explains the surprises: a listener that rolls the publisher back, an AFTER_COMMIT listener that silently never runs, and an async listener that sees a different world. Every claim is reproduced on Spring Boot 4.1 with a committed transcript, including a rollback that proves AFTER_COMMIT semantics.

Write Your Own Spring Boot 4 Starter: Auto-Configuration, @Conditional and Properties

Build a real Spring Boot 4.1 starter from an empty directory: the two-jar layout, AutoConfiguration.imports, @ConditionalOnMissingBean back-off, configuration metadata, an optional Jackson 3 integration, and the ApplicationContextRunner test that passes while the starter is broken. Every claim comes from a committed transcript.

Circular Dependencies in Spring Boot 4: Why Startup Fails and 4 Ways to Fix It

Spring Boot 4 refuses to start with "The dependencies of some of the beans in the application context form a cycle". This article reproduces the failure, reads the report, and applies four fixes (redesign, events, @Lazy, ObjectProvider), plus what allow-circular-references really does on Spring Framework 7.0.9. Every claim comes from a committed test transcript.