How can I generate Q-classes with QueryDsl 4.1.4 and Spring-Data-Jpa 2.0.0.M1?

2.1k views Asked by At

I would like to update my version of Querydsl. I was looking for generating Q-Classes with the apt-maven-plugin like this:

<plugin>
    <groupId>com.mysema.maven</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>1.1.3</version>
    <executions>
        <execution>
             <goals>
                  <goal>process</goal>
              </goals>
              <configuration>
                  <outputDirectory>target/generated-sources/java</outputDirectory>
                  <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
              </configuration>
          </execution>
     </executions>
</plugin>

Some versions I 'm using:

<spring.security.version>4.2.0.RELEASE</spring.security.version>
<spring.context.version>4.3.4.RELEASE</spring.context.version>
<springdata.jpa.version>2.0.0.M1</springdata.jpa.version>
<springdata.es.version>2.0.5.RELEASE</springdata.es.version>
<springdata.common.version>2.0.0.M1</springdata.common.version>
<querydsl.version>4.1.4</querydsl.version>

But unfortunalty this generates me nothing on the generated-sources folder as expected. So can you give me some ways to understand what has failed in my Querydsl configuration please?

Thanks per advance.

1

There are 1 answers

2
manish On

Make sure that the querydsl-apt library is available on the build classpath.

Option 1: Add the library as a dependency to the APT plugin

<plugin>
  <groupId>com.mysema.maven</groupId>
  <artifactId>apt-maven-plugin</artifactId>
  <version>1.1.3</version>
  <dependencies>
    <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>
      <version>${querydsl.version}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <goals>
        <goal>process</goal>
      </goals>
      <configuration>
        <outputDirectory>target/generated-sources/java</outputDirectory>
        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
      </configuration>
    </execution>
  </executions>
</plugin>

Option 2: Add the library as a project dependency

<project>
  ..
  <dependencies>
    <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>
      <version>${querydsl.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

Note <scope>provided</scope> in this case, which will ensure that the library does not get bundled with the application.