0
votes

I'm trying to have a Spring Data Couchbase configuration.

Here is the configuration class:

@Configuration
@EnableCouchbaseRepositories(basePackages = { "com.thalasoft.data.couchbase.repository" }, basePackageClasses = { BaseRepository.class })
public class CouchbaseConfiguration extends AbstractCouchbaseConfiguration {

  private static Logger logger = LoggerFactory.getLogger(CouchbaseConfiguration.class);

  @Autowired
  private CouchbaseProperties couchbaseProperties;

  @Override
  protected List<String> getBootstrapHosts() {
    return Collections.singletonList(couchbaseProperties.getHost());
  }

  @Override
  protected String getBucketName() {
    return couchbaseProperties.getBucketName();
  }

  @Override
  protected String getBucketPassword() {
    return couchbaseProperties.getBucketPassword();
  }
}

I get the following error:

Invalid default: public abstract java.lang.Class org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories.repositoryBaseClass()

I also tried with:

@EnableCouchbaseRepositories(basePackages = { "com.thalasoft.data.couchbase.repository" })

But I get the exact same error.

I also then tried with:

@EnableCouchbaseRepositories(basePackages = { "com.thalasoft.data.couchbase.repository" }, repositoryBaseClass = BaseRepository.class )

But I get the exact same error.

My Couchbase instance is running and accessible.

I'm using Spring 4.2.0.RELEASE with spring-data-couchbase 2.0.0.M1 against Couchbase 2.5.1 enterprise edition (build-1083)

The repository is:

public interface AnswerRepository extends BaseRepository<Answer, String> {

  @View(viewName = "answers_by_id")
  public List<Answer> findById(String id);

  Answer findByUuid(String uuid);

}

@NoRepositoryBean
public interface BaseRepository<T, ID extends Serializable> extends Repository<T, ID>  {
}
1
have you tried having AnswerRepository directly extend CrudRepository<Answer, String> or even CouchbaseRepository<Answer, String>? - Simon Baslé
Reading the documentation, I understood I could not use the CrudRepository class since my CB instance probably does not offer the views matching the CRUD methods. I'm a noob with CB I must say. - Stephane
So I just tried this: public interface AnswerRepository extends Repository<Answer, String> but it gave me the exact same error. - Stephane
I now see I have a similar error when building another non dependent project. It gives me the following error: java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.jpa.repository.config.EnableJpaRepositories.repositoryBaseClass() This project would normally build. - Stephane
The other project succeeds when going back from the spring-data-jpa 1.9.1.RELEASE version to the 1.6.2.RELEASE version. Something similar must be at play with the spring-data-couchbase project. If I could make this project succeed with the spring-data-jpa 1.9.1.RELEASE version then the couchbase project would probably succeed too. - Stephane

1 Answers

0
votes

You have to use CRUDRepository as a base interface, or one of its child interfaces.

Also Spring Data Couchbase requires to have one backing view for CRUD operations to work. To additionally have paging and sorting (by extending PagingAndSortingRepository) or query derivation from method names, you'll also need a primary N1QL index.

Note that in the upcoming Release Candidate there will be an option in the configuration to auto-create the views/indexes you need, but it's usually safer to create them by hand since, depending on the number of documents already stored, it can be a costly operation...