Upgrade to Spring Boot 3.0: javax.* to jakarta.* in 1 second

Spring Boot 3.0 was released 24th of November, 2022. It brought many great changes, like migration to Java 17 and Native Spring Boot executables. It’s a compelling release to update projects to. Also, all packages were migrated from javax.* package to jakarta.*. I found it annoying to change packages in each file one by one, so I came up with a simple one-liner that does this job for me:

find . -name '*.java' -exec sed -i 's/javax/jakarta/g' {} +

This script does the following: finds all “*.java” files in the current directory passes them to sed sed replaces javax with jakarta in each of them

Usage:

  1. Save/Commit all your changes
  2. Navigate to src folder of your Spring Boot project in terminal
  3. Execute one-liner
  4. Enjoy packages updated to Spring Boot 3.0 standards

That’s it. Thanks for reading. Happy Spring Boot 3.0 migration!