Spring Roo生成未知域模型

时间:2018-06-12 09:00:14

标签: java spring-boot spring-roo

我刚开始使用Spring Roo,在使用实体生成简单项目时遇到问题。我正在关注DZone的一篇文章。

DZone How to generate spring boot application

当我按照步骤操作时,我会生成一个名为owner的域模型,其中包含2个字段

  1. 用户名

  2. 电子邮件

  3. 当我完成生成项目后,它更正了所有者模型,但代码中有对QOwner的引用,无法找到它们的类。

    @RooJpaRepositoryCustomImpl(repository = OwnerRepositoryCustom.class)
    public class OwnerRepositoryImpl extends QueryDslRepositorySupport{
    
        OwnerRepositoryImpl() {
            super(Owner.class);
        }
    
        private JPQLQuery getQueryFrom(QOwner qEntity){
            return from(qEntity);
        }
    }
    

    OwnerRepositoryImple_Roo_Jpa_Repository_Impl.java

1 个答案:

答案 0 :(得分:2)

请记住,Q类是由querydsl-maven-plugin生成的,因此您必须使用mvn clean compile编译项目才能使这些类可用。

之后,如果您使用的是Eclipse STS或IntelliJ,则需要将生成此Q类的文件夹( target / generated-sources / java )标记为{{ 1}}允许您的IDE检测它们。

希望它有所帮助,