我最近在我们的一个项目中开始使用 ReactiveCouchbaseRepository (spring-data-couchbase - 3.0.0.M2,spring-boot-starter-parent - 2.0.0.M2)。
我提到了unpublished doc from here并设置了项目,但我收到了以下错误。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dummyRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property saveAll found for type Dummy!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1717) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:305) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:233) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:303) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:250) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
以下是有关设置项目的相关信息。
@Maven
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
<version>3.0.0.M2</version>
</dependency>
@java
//Repository class
public interface DummyRepository extends ReactiveCouchbaseSortingRepository<Dummy, String> {
}
//Model class
public class Dummy {
@Id
private final String id;
@Field
private final String name;
@Field
private final String address;
...
}
//Java config class
@Configuration
@EnableReactiveCouchbaseRepositories
public class CouchbaseDatabaseConfig extends AbstractReactiveCouchbaseConfiguration {
...
}
现在,我确实经历了this和this,但这里我没有在 DummyRepository 类中编写的自定义方法。
当我从 ReactiveCouchbaseSortingRepository 更改为 CouchbaseRepository 时,注意,一切正常。
感谢您的帮助。
答案 0 :(得分:1)
似乎我们只需要添加以下依赖项来实现 saveAll 。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
ps:感谢 Subhashni Balakrishnan 在couchbase forums - here上回答了
答案 1 :(得分:0)
您应该在方法上添加@Query,否则jpa会将其视为属性