我正在尝试使用此处描述的替代方法从groovy实体生成querydsl类http://www.querydsl.com/static/querydsl/2.7.3/reference/html/ch03s02.html
我遇到的问题是这些类只在我执行mvn编译/包两次
时生成即。有关顺序的东西,应该在编译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>
我缺少什么?
答案 0 :(得分:2)
你需要:
再次编译生成的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>