我在春季启动时使用@Document和@Entity注释制作了一个实体。代码如下:-
//代码
@Entity
@Document(indexName = "content", type = "doc")
public class Content implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long contentId;
@Field(type = Date)
@Column(updatable=false, insertable=false)
private LocalDateTime dateAdded;
@Field(type = Date)
@Column(updatable=false, insertable=false)
private LocalDateTime dateModified;
...... With getter and setter basically. Normal POJO basically.
}
我已经使用:-
//代码
@Repository
public interface ElasticSearch extends ElasticsearchRepository<Content, Long>{
@Query("{"bool": {"must": [{"match": {"authors.name": "?0"}}]}}")
Page findByAuthorsNameUsingCustomQuery(String name, Pageable pageable);
@Query("{"bool": {"must": {"match_all": {}}, "filter": {"term": {"tags": "?0" }}}}")
Page vf(String tag, Pageable pageable);
@Query("{"bool": {"must": {"match": {"authors.name": "?0"}}, "filter": {"term": {"tags": "?1" }}}}")
Page findByAuthorsNameAndFilteredTagQuery(String name, String tag, Pageable pageable);
}
但是,一旦我运行Spring Boot应用程序,我的系统就会发出类似:-
的错误org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名称为“ contentController”的bean时出错:不满意 通过字段“ contentSearchService”表示的依赖关系;嵌套的 例外是 org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名称为“ contentSearchImpl”的bean时出错:不满意 通过字段“ contentSearch”表示的依赖关系;嵌套异常 是org.springframework.beans.factory.BeanCreationException:错误 创建名称为“ contentSearch”的Bean:初始化方法的调用 失败嵌套异常为java.lang.IllegalArgumentException:失败 为方法public abstract java.lang.Object创建查询 org.springframework.data.elasticsearch.repository.ElasticsearchRepository.index(java.lang.Object)! 找不到内容类型的属性索引!在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) 〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
在org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) 〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
我尝试了很多事情。有人可以帮忙吗?