Spring Data JPA - Specifications and Querydsl
Instead of explicitly configuring the apt-maven-plugin
just add the following dependency to the project (note the jpa
classifier):
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<classifier>jpa</classifier>
</dependency>
Also, if you want more Querydsl features than what QuerydslPredicateExecutor
has to offer check out https://github.com/infobip/infobip-spring-data-querydsl#JPA.
The way I could make this work was using the com.querydsl.apt.jpa.JPAAnnotationProcessor instead of the com.mysema.query.apt.jpa.JPAAnnotationProcessor and by changing the dependencies as follow:
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.0.6</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.0.6</version>
</dependency>
The plugin end up like this:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
I also executed in the command line at the projects root mvn eclipse:eclipse to update Eclipse to include the generated sources.
Update:
Replaced the plugin maven-apt-plugin for apt-maven-plugin and changed version to 1.1.3