使用外部jar中的休眠实体 [英] Use hibernate entities from external jar

查看:98
本文介绍了使用外部jar中的休眠实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了jhipster微服务应用程序,在其中添加了一个"demographics.jar"文件作为依赖项.

I have created jhipster microservice application, in which i have added a "demographics.jar" file as a dependency.

demographics.jar文件包含JPA实体"Address.java"类.

demographics.jar file contains a class "Address.java" which is JPA entity.

当我从代码中引用此类时,它会产生以下错误

when i refer this class from my code, it generated following error

org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.example.jobcard.domain.JobCard.location references an unknown entity: com.example.geographics.domain.Address
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:109)
    at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1598)
    at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1521)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1422)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    ... 28 common frames omitted

jhipster版本是:3.6.1

jhipster version is : 3.6.1

jdk版本是:1.8.0_91

jdk verison is : 1.8.0_91

这是父pom详细信息:

here is the parent pom details :

<parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>1.4.0.RELEASE</version>
        <relativePath/>
    </parent>

我已经准备好许多建议编辑persistence.xml文件的解决方案,但是perhip.xml文件不是jhipster生成的.

I have ready many solutions which suggest to edit the persistence.xml file, but persistence.xml file is not generated by jhipster.

推荐答案

您的@EntityScan批注可能是错误的,以扫描您的2个软件包:com.example.jobcard.domaincom.example.geographics.domain

Your @EntityScan annotation is probably wrong to scan your 2 packages: com.example.jobcard.domain and com.example.geographics.domain

这篇关于使用外部jar中的休眠实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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