spring-data-couchbase – org.springframework.data.mapping.model.MappingException : Spring Boot

spring-data-couchbase – org.springframework.data.mapping.model.MappingException : Spring Boot



Caused by: org.springframework.data.mapping.MappingException: An ID property is needed, but not found/could not be generated on this entity.
This can happen if we are missing @Id for unique identifier field. Couchbase itself identifies each Document by its unique ID, or missing Id GenerationStrategy.
The following helped me to resolve the issue
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.couchbase.core.mapping.Document;
import org.springframework.data.couchbase.core.mapping.id.GeneratedValue;
import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Document
@Data
public class User {

    @Id
    @GeneratedValue(strategy = GenerationStrategy.UNIQUE)
    private String id;
 Hope this helps :)

No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days