QueryDsl代码生成不会生成Q类

QueryDsl代码生成不会生成Q类

本文介绍了Java QueryDsl代码生成不会生成Q类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个Spring项目,其中我在实体上使用QueryDsl.我从几个月前开始接手这个项目,在那里我已经有1个生成的类(QUser).现在,我创建了一个名为Permission的新实体,并修改了User实体.当我构建项目时,QUser不会更改,并且QPermission类也不会生成.我究竟做错了什么?这是QueryDsl的实体和pom.xml.

I'm making a Spring project, where i'm using QueryDsl for the entities. I'm picking up this project from a few months back, where i already had 1 generated class (QUser). Now i made a new entity called Permission, and modified the User entity. When i'm building the project, the QUser doesn't change, and the QPermission class is not generating either. What am i doing wrong? Here's the entity and pom.xml for QueryDsl.

@Entity
@Table(name = "permission")
public class Permission {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Long id;

   @Column(name = "name", length = 100, nullable = false)
   private String name;


   public Long getId() {
       return id;
   }

   public void setId(Long id) {
       this.id = id;
  }

    public String getName() {
       return name;
   }
    public void setName(String name) {
        this.name = name;
    }
}

和pom.xml:

[..]
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <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>
[...]

我正在关注文档: http://www.querydsl.com/static/querydsl/3.2.0/reference/html/ch03s03.html 我正在使用IntellIJ IDEA,也尝试了重建项目"选项.

I was following the documentation:http://www.querydsl.com/static/querydsl/3.2.0/reference/html/ch03s03.htmlI'm using IntellIJ IDEA and tried the "Rebuild project" option as well.

推荐答案

可以显示放在pom.xml中的依赖项吗?

Can you show the dependencies you put in your pom.xml ?

我从头开始进行了一些测试

I've made some tests starting from scratch

这里是依赖项:

<dependencies>
    ...
    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>4.2.1</version>
    </dependency>
    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>4.2.1</version>
    </dependency>
    ...
</dependencies>

还有插件:

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

我尝试生成QFiles的完整源代码,并且有效:

The complete source code I've tried to generate QFiles and that worked :

https://github.com/githubjul/test-so-querydsl

我不运行项目,只是编译它以验证它是否有效.

I don't run the project, only compile it to verify it works.

这篇关于Java QueryDsl代码生成不会生成Q类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:32