我一起使用 Spring-data-Neo4J 和 Spring-data-MongoDb。在 UserRepository 上调用 save 方法会产生错误。任何帮助将不胜感激。
我的域类
@Document
@NodeEntity(partial=true)
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@GraphId Long id;
@Id
private String userId;
private String firstName;
private String lastName;
@GraphProperty
private String username;
以下是错误日志:
java.lang.ClassCastException: org.springframework.data.neo4j.support.mapping.Neo4jPersistentEntityImpl 不能转换为 org.springframework.data.mongodb.core.mapping.MongoPersistentEntity org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator。 onApplicationEvent(MongoPersistentEntityIndexCreator.java:79) org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.onApplicationEvent(MongoPersistentEntityIndexCreator.java:47) org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97) org. springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324) org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:263) org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:165) org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:140) org.springframework.data.neo4j.support.Neo4jTemplate。 getPersistentEntity(Neo4jTemplate.java:573) org.springframework.data.neo4j.support.Neo4jTemplate.getMappingPolicy(Neo4jTemplate.java:470) org.springframework.data.neo4j.support.Neo4jTemplate.getMappingPolicy(Neo4jTemplate.java:631) org. springframework.data.neo4j.support.Neo4jTemplate.save(Neo4jTemplate.java:295) org.springframework.data.neo4j.repository.AbstractGraphRepository.save(AbstractGraphRepository.java:106) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun .reflect.NativeMethodAccessorImpl。调用(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)org.springframework.data.repository.core.support。 RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:323) org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:308) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation. java:172) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.dao。support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) $Proxy82 .save(未知来源) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect .Method.invoke(Method.java:597) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java: 172)org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)$Proxy84.save(未知来源)202)$Proxy84.save(未知来源)202)$Proxy84.save(未知来源)