Wie verwenden Sie sowohl Spring Data JPA- als auch Spring Data Elasticsearch-Repositorys in derselben Domänenklasse in einer Spring Boot-Anwendung?

Ich versuche, sowohl Spring Data JPA als auch Spring Data Elasticsearch für dasselbe Domänenobjekt zu verwenden, aber das funktioniert nicht.

Wenn ich versucht habe, einen einfachen Test durchzuführen, ist folgende Ausnahme aufgetreten:

org.springframework.data.mapping.PropertyReferenceException: Kein Eigenschaftsindex für Typ Person gefunden! at org.springframework.data.mapping.PropertyPath. (PropertyPath.java:75) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.mapping.PropertyPath.create (PropertyPath .java: 327) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.mapping.PropertyPath.create (PropertyPath.java:307) ~ [spring-data-commons- 1.11.0.RELEASE.jar: na] at org.springframework.data.mapping.PropertyPath.from (PropertyPath.java:270) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org. springframework.data.mapping.PropertyPath.from (PropertyPath.java:241) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] bei org.springframework.data.repository.query.parser.Part. ( Part.java:76) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.repository.query.parser.PartTree $ OrPart. (PartTree.java:235) ~ [ spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.repository.query.parser.PartTree $ Predicate.buildTree (PartTree.java:373) ~ [spring-data-commons-1.11 .0.RELEASE.jar: na] at org.springframework.data.repository.query.parser.PartTree $ Predicate. (PartTree.java:353) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data .repository.query.parser.PartTree. (PartTree.java:84) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.jpa.repository.query.PartTreeJpaQuery. ( PartTreeJpaQuery.java:61) ~ [spring-data-jpa-1.9.0.RELEASE.jar: na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ CreateQueryLookupStrategy.resolveQuery (JpaQueryLookupStrategy) [spring-data-jpa-1.9.0.RELEASE.jar: na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ CreateIfNotFoundQueryLookupStrategy.resolveQuery (JpaQueryLookupStrategy.java:206) ~ 1.9.0.RELEASE.jar: na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ AbstractQueryLookupStrategy.resolveQuery (JpaQueryLookupStrategy.java:73) ~ [spring-data-jpa-1.9.0.RELEASE : na] bei org.springframework.data.repository.c ore.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor. (RepositoryFactorySupport.java:408) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository. RepositoryFactorySupport.java:206) ~ [spring-data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn (RepositoryFactoryBeanSupport.java:251) ~ [spring -data-commons-1.11.0.RELEASE.jar: na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet (RepositoryFactoryBeanSupport.java:237) ~ [spring-data-commons-1.11.0. RELEASE.jar: na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet (JpaRepositoryFactoryBean.java:92) ~ [spring-data-jpa-1.9.0.RELEASE.jar: na] at org. springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1637) ~ [sp ring-beans-4.2.1.RELEASE.jar: 4.2.1.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1574) ~ [spring-beans-4.2.1.RELEASE .jar: 4.2.1.RELEASE] ... 43 allgemeine Frames wurden weggelassen

Sie arbeiten, wenn Sie eines von beiden deaktivieren.

Das Projekt basiert auf Spring Boot 1.3.0.M5.

Dies ist ein Beispielprojekt, das die Situation reproduziert:

https: //github.com/izeye/spring-boot-throwaway-branches/tree/data-jpa-and-elasticsearc

Antworten auf die Frage(4)

Ihre Antwort auf die Frage