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

你离开我真会死。 提交于 2019-12-11 07:34:41

问题


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:


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.



来源:https://stackoverflow.com/questions/41386005/how-can-i-generate-q-classes-with-querydsl-4-1-4-and-spring-data-jpa-2-0-0-m1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!