how to reference JPA annotated classes from jar dependency to generate QueryDsl Q classes?

南笙酒味 提交于 2021-01-28 00:06:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!