本文介绍了如何使用QueryDsl 4.1.4和Spring-Data-Jpa 2.0.0.M1生成Q类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新我的Querydsl版本.我一直在寻找使用apt-maven-plugin生成Q类的方法:

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>

但是不幸的是,这并没有像预期的那样对我产生任何影响.那么,您能给我一些方法来了解Querydsl配置失败的原因吗?

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?

谢谢你.

推荐答案

确保querydsl-apt库在构建类路径中可用.

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

<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>


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

在这种情况下,请注意<scope>provided</scope>,这将确保该库不会与应用程序捆绑在一起.

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

这篇关于如何使用QueryDsl 4.1.4和Spring-Data-Jpa 2.0.0.M1生成Q类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:24