Skip to content

JPA Maven setup in docs no longer works on JDK 23+; need update to annotationProcessorPaths #1880

Description

@q975144677

Important Notice

Thank you for opening an issue! Please note that, as outlined in the
README, I currently only
work on feature requests or bug fixes when sponsored. Balancing this project with professional and personal priorities
means I have a very limited amount of effort I can divert to this project.

You must put in the work to address this issue, or it won't be addressed.

  • I am willing to put in the work and submit a PR to resolve this issue.

Is your feature request related to a problem? Please describe.

Yes — the documented JPA setup no longer generates Q classes on modern JDKs, which makes the official documentation
actively misleading for new users.

The JPA tutorial at https://openfeign.github.io/querydsl/tutorials/jpa/querydsl instructs users to configure the
annotation processor via the maven-compiler-plugin's own <dependencies> block:

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <generatedSourcesDirectory>target/generated-sources/java</generatedSourcesDirectory>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>io.github.openfeign.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>
      <version>7.1</version>
      <classifier>jpa</classifier>
    </dependency>
    <dependency>
      <groupId>jakarta.persistence</groupId>
      <artifactId>jakarta.persistence-api</artifactId>
      <version>3.1.0</version>
    </dependency>
  </dependencies>
</plugin>

This approach relies on implicit annotation processing, where javac auto-discovers processors on the classpath.
Implicit annotation processing was deprecated in JDK 21 and fully removed in JDK 23. On JDK 23+ (I'm on JDK 25),
this configuration is silently ignored — no Q classes are produced.

Meanwhile, the referenced Examples instead put querydsl-apt as a project-level dependency:

<dependency>
  <groupId>io.github.openfeign.querydsl</groupId>
  <artifactId>querydsl-jpa</artifactId>
  <version>7.5</version>
</dependency>
<dependency>
  <groupId>io.github.openfeign.querydsl</groupId>
  <artifactId>querydsl-apt</artifactId>
  <version>7.5</version>
  <classifier>jpa</classifier>
</dependency>

But Maven does not recognize querydsl-apt as an annotation processor from a plain project dependency on JDK 23+.
Here is the confusing symptom: IntelliJ IDEA's "Build" generates Q classes correctly (IDEA runs its own
annotation-processing pipeline and picks up processors from the module classpath), but after mvn clean, neither mvn compile, mvn install, nor mvn package produces Q classes.
This divergence between IDE builds and Maven builds
is very easy to mistake for a user error.

Describe the solution you'd like

Please update the JPA tutorial documentation to use the modern, explicit annotationProcessorPaths configuration,
which works reliably across JDK versions (including 23+):

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.13.0</version>
      <configuration>
        <proc>full</proc>
        <generatedSourcesDirectory>${project.build.directory}/generated-sources/java</generatedSourcesDirectory>
        <annotationProcessorPaths>
          <path>
            <groupId>io.github.openfeign.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>7.5</version>
            <classifier>jpa</classifier>
          </path>
          <path>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <version>3.1.0</version>
          </path>
        </annotationProcessorPaths>
      </configuration>
    </plugin>
  </plugins>
</build>

Two details matter here, and both are worth documenting explicitly:

  1. <proc>full</proc> — with implicit annotation processing removed on JDK 23+, this explicitly re-enables
    processing.
  2. jakarta.persistence-api must be listed inside annotationProcessorPathsannotationProcessorPaths runs
    the processor on an isolated classpath containing only the listed paths, so without JPA annotations the processor
    cannot inspect @Entity and silently produces nothing.

Describe alternatives you've considered

  • Keeping the current project-level querydsl-apt dependency: works in the IDE but not in Maven on JDK 23+; also
    leaks the processor to downstream consumers. Not a fix.
  • Sticking with the documented plugin <dependencies> block: only works on JDK 21 and earlier. Not a fix.
  • annotationProcessorPaths (chosen): the standard, recommended approach; explicit, isolated, and version-robust.

Additional context

  • JDK: 25 (behavior starts at JDK 23; deprecated in 21).
  • Maven: mvn compile / install / package all fail to generate Q classes.
  • I am happy to submit a PR to update the tutorial and any Examples docs that show the legacy configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions