gpt4 book ai didi

java - 使用 querydsl-maven-plugin 和 groovy-eclipse-compiler 生成 QueryDsl 类

转载 作者:行者123 更新时间:2023-12-02 04:16:59 26 4
gpt4 key购买 nike

我正在尝试使用此处描述的替代方法从groovy实体生成querydsl类http://www.querydsl.com/static/querydsl/2.7.3/reference/html/ch03s02.html

我面临的问题是,只有当我执行 mvncompile/package 两次时才会生成这些类

即按照顺序,应该在编译 groovy 类之前生成类

否则我会得到编译错误

Groovy:unable to resolve class com.application.domain.QUser

我的pom.xml

 <build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.3.7-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>3.6.8</version>
<executions>
<execution>
<id>generate-querydsl-classes</id>
<goals>
<goal>jpa-export</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<targetFolder>target/generated-sources/java</targetFolder>
<packages>
<package>com.application</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

我缺少什么?

最佳答案

您需要:

  1. 编译源 Groovy 代码
  2. 对类进行后处理以生成 QClass
  3. 再次编译生成的 QClass。

        <plugin>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-maven-plugin</artifactId>
    <version>${querydsl.version}</version>
    <executions>
    <execution>
    <id>generate-query-dsl-classes</id>
    <phase>process-classes</phase>
    <goals>
    <goal>jpa-export</goal>
    </goals>
    <configuration>
    <targetFolder>target/generated-sources/java</targetFolder>
    <packages>
    <package>com.my.package</package>
    </packages>
    </configuration>
    </execution>
    <execution>
    <id>compile-query-dsl-classes</id>
    <phase>process-classes</phase>
    <goals>
    <goal>compile</goal>
    </goals>
    <configuration>
    <sourceFolder>target/generated-sources/java</sourceFolder>
    </configuration>
    </execution>
    </executions>
    </plugin>

关于java - 使用 querydsl-maven-plugin 和 groovy-eclipse-compiler 生成 QueryDsl 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33201220/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com