java querydsl使用

1  POM文件

<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>

</parent>
<artifactId></artifactId>
<name></name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>

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

</project>

 


 

2 右键项目--Maven--Generate Sources and Update Folders

然后找到目录

target/generated-sources/java

 


拷贝生成好的QModel,复制到项目中,最后记得删除 java目录下的文件!

例子:

Predicate predicate = QSysUser.sysUser.userNameCn.equalsIgnoreCase("管理员");
        SysUser user = userService.findOne(predicate);

 

posted @ 2019-01-24 18:25  正怒月神  阅读(1116)  评论(0编辑  收藏  举报