Create (querydsl) metamodel for Entity from jar

。_饼干妹妹 提交于 2019-12-13 14:59:12

问题


I'm having problems generating the querydsl metamodel (i.e. the Q-classes) for an Entity comming from a jar included in the dependencies for my project.

The class (BaseEntity) is an abstract baseclass for most of my entities (annotated with @MappedSuperclass) and for project reasons and dependencies to other projects this baseclass has to be in a separate jar.

When I now include this jar as a dependency for the project which contains my non-abstract entities and try to generate the metamodel (using the com.mysema.maven:apt-maven-plugin) it doesn't recognize the BaseEntity and complains with "Cannot find symbol" QBaseEntity.

I kindof solved this by making maven unpack the source file (i.e. BaseEntity.java) into an additional source folder of the dependent project but this is kind of ugly as I have to always remember to change the version number in case of releases and also have the source dependency in my pom and it's also not very intuitive.

So my question(s) is/are:

  1. Can I make querydsl generate the metamodel for the class from the jar somehow without copying the source to the dependent project?
  2. If this is not possible: can I make querydsl metamodel generation operate on the .class file rather than on the .java source file (with that I wouldn't need the source dependency and could only extract the .class file from the existing dependency)

Any help is greatly appreciated, thanks


回答1:


You can use the QueryEntities annotation to refer to BaseEntity from the main source project. A package level annotation is advisable.




回答2:


You should add -info.java file in your package

@QueryEntities(value = {BaseEntity.class})
package xxxx.xxxx.xxx;

import com.querydsl.core.annotations.QueryEntities;
import xxx.xxxx.BaseEntity;


来源:https://stackoverflow.com/questions/24158170/create-querydsl-metamodel-for-entity-from-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!