【发布时间】:2018-02-25 02:34:47
【问题描述】:
我们有一个使用 Spring Boot + JPA/Hibernate 构建的服务。
我在不同的 jars/packages 中有两个同名的类。
使用 Eclipse 运行应用程序会导致 重复导入 问题,因此我在其中一个实体中添加了以下内容:
@Entity(name = "EnderecoCEP")
它解决了 Eclipse 中的问题,我可以很好地运行应用程序。但是,当使用 java -jar 运行 Spring Boot 生成的 jar 时,问题又回来了:
Caused by: org.hibernate.DuplicateMappingException: duplicate import: Endereco refers to both b.c.c.c.e.Endereco and b.c.c.d.e.Endereco (try using auto-import="false")
看起来@Entity(name) 属性被完全忽略了。我发现很多帖子抱怨类似问题(另一个 JAR 映射),但没有一个真正的解决方案。
【问题讨论】:
标签: hibernate jpa spring-boot spring-data-jpa