QueryDSL/APT和静态导入生成的类 [英] Classes generated by QueryDSL/APT and static imports

查看:125
本文介绍了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全新安装)将失败:

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和静态导入生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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