including Qclasses in the classpath

牧云@^-^@ 提交于 2019-12-11 09:37:34

问题


I generate My Qclasses in target/generated-sources/java and the Qclasses are generating good but when i want to use them in my src code /YY/src/controller/XXX.java for example like that

QLot lot = QLot.lot;

I get QLot cannot be resolved to a variable . It seems that the generated Qclasses are not in the classpath !!

<plugin>
      <groupId>com.mysema.maven</groupId>
      <artifactId>apt-maven-plugin</artifactId>
      <version>1.0.6</version>
      <executions>
        <execution> 
          <goals>
            <goal>process</goal>
          </goals>
          <configuration>
            <outputDirectory>target/generated-sources/java</outputDirectory>
            <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
          </configuration>
        </execution>
      </executions>
</plugin>

回答1:


You may try this (I assume you use Eclipse).

in pom.xml - Set the target path of the generated classes as /src/main/generated (target is not a good place, because everytime you execute mvn clean the target folder will be cleaned and this may confuse IDEs) - Optionally: Add generate-sources in block, to ensure code generation executed at expected phase and before compilation.

in Eclipse or in console: - Build the project with mvn clean package

in Eclipse Project Explorer view - Find generated folder in src/main and right click on it and select Build Path > Use as Source Folder.

This should fix "cannot be resolved to a variable" problems if you already enabled "Build Automatically" option.



来源:https://stackoverflow.com/questions/26833880/including-qclasses-in-the-classpath

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