在类路径中包括Qclasss [英] including Qclasses in the classpath

查看:137
本文介绍了在类路径中包括Qclasss的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 target / generation-sources / java 中生成我的Qclass,并且Qclasss生成良好,但是当我想在我的src代码中使用它们时 /YY/src/controller/XXX.java 例如

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;

我得到 QLot无法解析为变量。看来生成的Qclasses不在类路径中!

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>


推荐答案

您可以尝试一下(我假设您使用Eclipse) 。

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

in pom.xml
-将生成的类的目标路径设置为/ src / main / genic(目标不是一个好地方,因为每次您执行mvn clean,目标文件夹将被清除,这可能会使IDE混淆。
-可选:在代码块中添加generate-sources,以确保在预期阶段和编译之前执行代码生成。

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.

在Eclipse或控制台中:
-在Eclipse中使用mvn clean package构建项目

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

Project Explorer视图
-在src / main中找到生成的文件夹,然后右键单击它,然后选择构建路径>用作源文件夹。

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.

这篇关于在类路径中包括Qclasss的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆