gpt4 book ai didi

spring-boot - 属性引用异常 : No property findAll found for type

转载 作者:行者123 更新时间:2023-12-03 17:16:26 24 4
gpt4 key购买 nike

Spring Boot 应用

我有实体 Test两者都有 JpaRepositoryElasticSearchRepository当我单独使用其中一个存储库时,它的工作正常。但是当为 Test 实体创建两个存储库时,它抛出错误 bean 创建错误。No property findAll found for type Test!

@Data
@Table
@Entity
@Document(indexName = "test",type = "Test")
public class Test {

@Id
private Long id;
@Field
private String name;
}

public interface TestSearchRepository extends ElasticsearchRepository<Test,Long> {}

public interface FacilityRepository extends JpaRepository<Facility,Long> {}
*Error*:`eCaused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type Test!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:85) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:289) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:248) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:215) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:239) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[na:1.8.0_73]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_73]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_73]
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:240) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:368) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_73]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_73]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_73]
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:369) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:92) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery.<init>(ElasticsearchPartQuery.java:46) ~[spring-data-elasticsearch-3.0.0.BUILD-20170705.074610-104.jar:na]
at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory$ElasticsearchQueryLookupStrategy.resolveQuery(ElasticsearchRepositoryFactory.java:123) ~[spring-data-elasticsearch-3.0.0.BUILD-20170705.074610-104.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$null$0(RepositoryFactorySupport.java:491) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_73]
at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[na:1.8.0_73]
at java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1049) ~[na:1.8.0_73]
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_73]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_73]`

最佳答案

请尝试将 JPA et elasticsearch 存储库放在单独的包中,并使用以下显式配置以避免冲突:

@EnableJpaRepositories("my.jpa.repositories")
@EnableElasticsearchRepositories("my.search.repositories")

关于spring-boot - 属性引用异常 : No property findAll found for type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44964168/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com