Я кодирую приложение java для вставки данных в CouchDB. Для этого я использую Ektorp и получаю исключение org.ektorp.InvalidDocumentException: Cannot resolve id accessor in class
Это мои maven зависимости:
<dependency>
<groupId>org.ektorp</groupId>
<artifactId>org.ektorp</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.10</version>
</dependency>
POJO, как описано здесь
public class Item {
@JsonProperty("_index")
public String index;
@JsonProperty("_type")
public String type;
@JsonProperty("_id")
public String id;
@JsonProperty("_score")
public float score;
}
Репозиторий:
public class ItemRepository extends CouchDbRepositorySupport<Item> {
public ItemRepository(CouchDbConnector db) {
super(Item.class, db);
}
}
И как я пытаюсь добавить:
Item x = new Item();
x.id = "1291";
x.index="test_index";
x.score = 1;
x.type = "_doc";
this.repo = new ItemRepository(this.db);
this.repo.add(x);
Описание ошибки:
Exception in thread "main" org.ektorp.InvalidDocumentException: Cannot resolve id accessor in class org.example.Item
at org.ektorp.util.Documents$MethodAccessor.assertMethodFound(Documents.java:165)
at org.ektorp.util.Documents$MethodAccessor.<init>(Documents.java:136)
at org.ektorp.util.Documents.getAccessor(Documents.java:113)
at org.ektorp.util.Documents.getRevision(Documents.java:77)
at org.ektorp.util.Documents.isNew(Documents.java:85)
at org.ektorp.support.CouchDbRepositorySupport.add(CouchDbRepositorySupport.java:100)
at org.example.DataBase.addItem(DataBase.java:69)
at org.example.App.main(App.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Я не уверен, что делаю не так. Я думаю, что это библиотека Джексона JSON, в которой я не уверен Если я использую правильную библиотеку, так как ссылка, которую они имеют в do c, больше не существует.
Я ценю любую помощь