[英]Classes generated by QueryDSL/APT and static imports
Apparently I can't use classes generated with APT in unit tests that use static imports. 显然我不能在使用静态导入的单元测试中使用用APT生成的类。 (Maven sample project can be downloaded here ) (Maven示例项目可以在这里下载)
If the following sample class 如果是以下示例类
import com.mysema.query.jpa.impl.JPAQuery;
public class UserStore {
public void something() {
new JPAQuery(null).from(QUser.user).list(QUser.user.login);
}
}
is changed to 改为
import static something.QUser.user;
import com.mysema.query.jpa.impl.JPAQuery;
public class UserStore {
public void something() {
new JPAQuery(null).from(user).list(user.login);
}
}
the build process (mvn clean install) will fail: 构建过程(mvn clean install)将失败:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.466s
[INFO] Finished at: Wed May 30 16:05:40 CEST 2012
[INFO] Final Memory: 18M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project apt-bug: Compilation failure: Compilation failure:
...
( full error message ) ( 完整的错误消息 )
Does this mean that I cannot use these generated classes with static import in unit tests or is there a problem in the pom.xml files? 这是否意味着我不能在单元测试中将这些生成的类与静态导入一起使用,或者pom.xml文件中是否存在问题?
EDIT: 编辑:
POM file: http://pastebin.com/gvycZmXD POM文件: http : //pastebin.com/gvycZmXD
This might be related https://github.com/mysema/querydsl/issues/158 这可能与https://github.com/mysema/querydsl/issues/158有关
I have not yet had the time to investigate this. 我还没有时间对此进行调查。
Edit 编辑
This has apparently been fixed now in Java 7 现在已经在Java 7中修复了这个问题
I assume the problem is located in the static import, cause the error messages says the imported QUser.user is neither a class nor an interface. 我假设问题位于静态导入中,导致错误消息显示导入的QUser.user既不是类也不是接口。 This looks like the user is just an attribute of the Class QUser which would explain the error message. 这看起来像用户只是Class Quser的一个属性,它可以解释错误消息。
/home/xxx/apt-bug/src/main/java/something/UserStore.java:3: cannot find symbol
symbol : class QUser
location: package something
import static something.QUser.user;
^
/home/xxx/apt-bug/src/main/java/something/UserStore.java:3: static import only from classes and interfaces
import static something.QUser.user;
^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.