Spring Data JPA-规格和Querydsl [英] Spring Data JPA - Specifications and Querydsl

查看:417
本文介绍了Spring Data JPA-规格和Querydsl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将QueryDSL与Spring Data集成到我现有的项目中,我尝试了不同的示例,现在我决定坚持使用此

I'm trying to integrate QueryDSL to my existing project with Spring Data, I've tried different samples and now I've decided to stick to this one Advanced Spring Data JPA - Specifications and Querydsl.

问题:当我作为Maven生成源运行项目时,出现此错误

Problem: when I run the project as Maven generate-sources I get this error

error: Annotation processor 'com.mysema.query.apt.jpa.JPAAnnotationProcessor' not found

我正在将该插件添加到我的pom.xml中,如博客文章所示:

I'm adding this plugin to my pom.xml as the blog post indicates:

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

和依赖项:

<dependency>
     <groupId>com.mysema.querydsl</groupId>
     <artifactId>querydsl-sql</artifactId>
     <version>3.6.9</version>
</dependency>

任何人都可以向我指出正确的方向,以解决该问题或如何将QueryDSL正确集成到我的项目中?预先感谢!

Can anyone point me in the right direction on how to solve this or how to properly integrate QueryDSL to my project ? Thanks in advance!

推荐答案

我可以使用 com.querydsl .apt.jpa.JPAAnnotationProcessor代替 com .mysema.query .apt.jpa.JPAAnnotationProcessor并通过如下更改依赖项:

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>

插件最终如下:

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

我还在命令行中的项目根目录 mvn eclipse:eclipse 中执行了该操作,以更新Eclipse以包含生成的源代码.

I also executed in the command line at the projects root mvn eclipse:eclipse to update Eclipse to include the generated sources.

更新:

将插件maven-apt-plugin替换为apt-maven-plugin,并将版本更改为1.1.3

Replaced the plugin maven-apt-plugin for apt-maven-plugin and changed version to 1.1.3

这篇关于Spring Data JPA-规格和Querydsl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆