我有这个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
听起来我错过了一个依赖或什么?
我一直在关注这些链接:
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
解决方法
在项目中添加以下依赖项
<dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-jpa</artifactId> <version>4.0.3</version> </dependency>
版本号根据您的JPA版本.