No [ManagedType] was found for the key class [java.lang.Object] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>java.lang.Object</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:173) ~[org.eclipse.persistence.jpa-2.5.2.jar:na]
at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:495) ~[org.eclipse.persistence.jpa-2.5.2.jar:na]这很奇怪,因为恢复到SpringDataJPA1.4.3。because修复了这个问题。但我们想知道是什么原因造成了这种情况。我们使用的接口存储库如下所示
@Repository
public interface BaseRepository<T, K extends Serializable>
extends JpaRepository<T, K>,
QueryDslPredicateExecutor<T> {
}和
@Repository
public interface PersonRepository extends BaseRepository<Person, Long> { }在此期间,我们将使用旧版本,但我不知道要在哪里查找才能解决这个问题。有什么想法吗?
发布于 2014-12-02 22:58:04
tl;dr
正如参考文献中所述,需要用@NoRepositoryBean对中间存储库接口进行注释。一般来说,Spring数据存储库不需要使用@Repository进行注释。
详细信息
Spring版本直到1.4.x使用延迟实例化模型作为存储库接口。这意味着,如果没有人显式地引用特定的存储库接口,则不会创建存储库bean,因此不会对泛型类型进行评估。
在SpringData1.5 M1中,我们更改了它(更准确地说,SpringDataCommons1.7 M1 -参见这张票,但这正是JPA1.5 M1所依赖的),以便与整个Spring容器中使用的默认bean实例化模型对齐(热切实例化是默认的)。
这意味着,以前错误的中间接口(如您的BaseRepository )现在开始失败--引导的上下文在启动时评估它们的泛型信息。如上所述,建议的解决方法是在中间接口上使用@NoRepositoryBean,因为这将导致Spring数据忽略接口,因此根本不会尝试为其创建Spring。
发布于 2014-12-03 07:52:59
你在什么地方用BaseRepository做豆吗?如果没有,可以从其中删除@Repository注释,或者用@NoRepositoryBean替换
https://stackoverflow.com/questions/27250108
复制相似问题