Search code examples
spring-bootcompiler-errorsupgradelombokjava-21

Compilation error after upgrading to JDK 21 - "NoSuchFieldError: JCImport does not have member field JCTree qualid"


After upgrading to JDK 21, I have the following compilation error in my Spring Boot project:

Fatal error compiling: java.lang.NoSuchFieldError:
Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid'

Solution

  • The culprit is Lombok. The minimal Lombok version compatible with JDK 21 is 1.18.30.

    This implies that the minimal Spring Boot version is 3.1.4, unless you want to meddle with the Spring Boot autoconfiguration and set the Lombok version in your project differently from the Spring Boot BOM defined in spring-boot-dependencies.

    See: [BUG] Lombok 1.8.26 incompatible with JDK 21 #3393