本文介绍了Spring Boot + JPA + QueryDSL =找不到OrderSpecifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个pom.xml:
I have this pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<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>
</plugins>
</build>
这个实体:
@Entity
@Data
@Builder
public class DataDto {
@Id
private String id;
private String name;
}
这个仓库:
public interface DataRepo extends JpaRepository <DataDto,String>, QueryDslPredicateExecutor<DataDto> {
}
我收到此错误:
Error:(9, 8) java: cannot access com.mysema.query.types.OrderSpecifier
class file for com.mysema.query.types.OrderSpecifier not found
这听起来像我缺少依赖项或其他东西吗?
It sounds like I'm missing a dependency or something??
我一直在关注以下链接以提供帮助: http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integration http://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl
I've been following these links to help:http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integrationhttp://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl
推荐答案
在项目中添加以下依赖项
Add following dependency in the project
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.0.3</version>
</dependency>
版本号(取决于您的JPA版本).
Version number according to the your JPA version.
这篇关于Spring Boot + JPA + QueryDSL =找不到OrderSpecifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!