问题
I have the @Entity annotated classes on Project A. Project B has a dependency on Project A.
I want to generate QueryDsl Q classes on Project B, so Project A would not have a dependency on QueryDsl.
If i follow the standard instructions (as described in http://www.querydsl.com/static/querydsl/4.1.3/reference/html_single/) to enable QueryDsl with JPA on Project B, it does not detect the annotated classes on project B.
According to this Github issue (https://github.com/querydsl/querydsl/issues/196), this is not possible, unless using an annotation on the package level. It dates 2012, so it might be possible now. Is it?
Thanks.
回答1:
Just found the answer:
Add to the pom file:
<plugin>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>jpa-export</goal>
</goals>
<configuration>
<targetFolder>target/generated-sources/java</targetFolder>
<packages>
<package>package.containing.entities</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>
来源:https://stackoverflow.com/questions/42421304/how-to-reference-jpa-annotated-classes-from-jar-dependency-to-generate-querydsl