Kshitiz Sharma
Kshitiz Sharma

Reputation: 792

Couchbase configuration not found in Spring Boot

I am trying to create a simple Spring boot application. When I run the application, it fails to start giving this error:

Caused by: java.io.FileNotFoundException: class path resource [org/springframework/data/couchbase/config/AbstractCouchbaseDataConfiguration.class] cannot be opened because it does not exist

I am not using Couchbase, still it is showing this error. My pom.xml file:

<dependencies>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

Upvotes: 0

Views: 1668

Answers (2)

Nesteban
Nesteban

Reputation: 26

I had exactly the same error in one personal projects, at the test phase. I found out the message was appearing because by mistake I had a test class using SpringBootApplication.class as the base configuration class, like this:

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = { SpringBootApplication.class })
public class ControllerTest {
...

It appeared to start scanning all autoconfiguration modules , including AbstractReactiveCouchbaseDataConfiguration. Just deleted the classes attribute, the error dissapeared and tests executed OK.

Upvotes: 0

Boris
Boris

Reputation: 24443

To start using Couchbase you need to add a Spring Boot Starter dependency:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>

See here for more details.

Note: you can use the Spring Initializr if you're not sure which dependencies are needed.

Upvotes: 1

Related Questions