I have a Spring Boot Service which is connecting to Couchbase Db to perform basic Crud operations using spring-boot-starter-data-couchbase.
Spring Boot Version = 3.0.5 spring-boot-starter-data-couchbase version = 3.0.5
My Pom.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.5</version>
</parent>
<groupId>com.example.librarymgt</groupId>
<artifactId>org_libmgt_v1_svc</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>org_libmgt_v1_svc</name>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.0.9</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
</dependencies>
</project>
My Couchbase Config:
@Configuration
@EnableCouchbaseRepositories(basePackages = {"org.libmgt.repository"})
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
...
}
Repository Looks like:
package org.libmgt.repository;
import org.springframework.data.couchbase.repository.Collection;
import org.springframework.data.couchbase.repository.CouchbaseRepository;
import org.springframework.data.couchbase.repository.Query;
import org.springframework.data.couchbase.repository.Scope;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@Scope("library_mgt")
@Collection("students")
public interface StudentsRepository extends CouchbaseRepository<Students, String> {
}
On starting the application the service is giving following exception:
Handler dispatch failed: java.lang.NoClassDefFoundError: com/couchbase/client/core/api/query/CoreQueryOptions
The same code was working fine with Spring Boot 2.7.7 before. Stopped working after Spring Boot migration to 3.x.
According to this issue this is related to the queryDSL being removed. The current solution is to add it back to your dependencies: