我正在按照本教程创建一个 spring 应用程序这是我的主课package com.example.webtool;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.data.solr.repository.config.EnableSolrRepositories;@SpringBootApplication@EnableSolrRepositories( basePackages = "com.example.webtool.repository")public class WebtoolApplication { public static void main(String[] args) { SpringApplication.run(WebtoolApplication.class, args); }}这是我的存储库类package com.example.webtool.repository;import java.util.List;import org.springframework.data.solr.repository.SolrCrudRepository;import com.example.webtool.model.Document;import org.springframework.stereotype.Service;public interface DocumentRepository extends SolrCrudRepository<Document, String> { List<Document> findAllByPerson(String person); // find documents whose person name matches the name of the person in the query List<Document> findAllByRank(String rank); // find documents whose rank matches the rank of the person in the query}这是我的文档类package com.example.webtool.model;import org.apache.solr.client.solrj.beans.Field;import org.springframework.data.solr.core.mapping.SolrDocument;@SolrDocument(solrCoreName = "gettingstarted")public class Document { @Field private String person; @Field private String rank; @Field private String text; public Document() { } public Document(String person, String rank, String text) { this.person = person; this.rank = rank; this.text = text; } public String getPerson() { return person; } public void setPerson(String person) { this.person = person; } public String getRank() { return rank; } public void setRank(String rank) { this.rank = rank; } public String getText() { return text; } public void setText(String text) { this.text = text; }}
1 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
错误日志告诉你:
Required identifier property not found for class com.example.webtool.model.Document!
@Id
@Indexed(name = "id", type = "string")
private String id;
添加回答
举报
0/150
提交
取消