没有使用QueryDsl版本更新生成QClasses

时间:2017-12-20 14:33:13

标签: maven jpa querydsl

我使用JPAQueryDsl 3.4.1配置此配置,一切正常,我生成了QClasses。

    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>3.4.1</version>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>3.4.1</version>
    </dependency>

    ....

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

但是当我尝试更新版本4.1.3时,JPAAnnotationProcessor更改为com.mysema.query.apt.jpa.JPAAnnotationProcessor 和官方doc中的apt-maven-plugin版本1.1.3一样,目录target/generated-sources/java为空,且不会生成QClasses

<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-apt</artifactId>
  <version>4.1.3</version>
</dependency>

<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-jpa</artifactId>
  <version>4.1.3</version>
</dependency>

...

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

1 个答案:

答案 0 :(得分:0)

使用此插件:

<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <configuration>
        <defaultOutputDirectory>target/generated-sources/java</defaultOutputDirectory>
        <processors>
            <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
        </processors>
    </configuration>
    <executions>
        <execution>
            <id>process</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>process</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>4.1.4</version>
        </dependency>
    </dependencies>
</plugin>