本文介绍了QueryDSL/APT 和静态导入生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
显然我不能在使用静态导入的单元测试中使用 APT 生成的类.(Maven 示例项目可以在这里下载)
Apparently I can't use classes generated with APT in unit tests that use static imports. (Maven sample project can be downloaded here)
如果下面的示例类
import com.mysema.query.jpa.impl.JPAQuery;
public class UserStore {
public void something() {
new JPAQuery(null).from(QUser.user).list(QUser.user.login);
}
}
改为
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);
}
}
构建过程(mvn clean install)将失败:
the build process (mvn clean install) will fail:
[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:
...
(完整的错误信息)
这是否意味着我不能在单元测试中使用这些生成的带有静态导入的类,或者 pom.xml 文件中存在问题?
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 文件:http://pastebin.com/gvycZmXD
推荐答案
这可能是相关的 https://github.com/mysema/querydsl/issues/158
我还没有时间对此进行调查.
I have not yet had the time to investigate this.
编辑
这显然已在 Java 7 中修复
This has apparently been fixed now in Java 7
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7174857
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7159016
这篇关于QueryDSL/APT 和静态导入生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!