Spring Data Elasticsearch 启动报错 org.springframework.beans.factory.UnsatisfiedDependencyException 依赖不足

Spring Data Elasticsearch 启动报错 

 对文档映射对象coursedoc修改后启动服务报错

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchController': Unsatisfied dependency expressed through field 'courseElasticsearchRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'courseElasticsearchRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: mapper [name] of different type, current_type [text], merged_type [keyword]

 

创建名为“”org.springframework.beans.factory.UnsatisfiedDependencyException:searchController“”的Bean时出错:通过字段“”CourseElasticsearchRepository“”表示的依赖项不满足;嵌套异常是创建名为“”CourseElasticsearchRepository“”的Bean时出现org.springframework.beans.factory.BeanCreationException:错误:调用init方法失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]:构造函数引发的异常;嵌套异常是java.lang.IllegalArgumentException:不同类型、CURRENT_TYPE[TEXT]、MERMERED_TYPE[KEYWORD]的映射器[NAME]。“

 

然后想通过ElasticsearchTemplate 的方法来删除索引重新创建

@Test
public void testesdelindex(){
    elasticsearchTemplate.deleteIndex(CourseDoc.class);
}

报错,无法执行

最后,打开kibana

DELETE hrm   admin是我的索引名

GET _mapping 查询索引库被删除

再重新创建索引库

@Test
public void createIndex(){
    //创建索引库
    elasticsearchTemplate.createIndex(CourseDoc.class);
    //文档映射
    elasticsearchTemplate.putMapping(CourseDoc.class);
}

最后发现了一片介绍Spring Data Elasticsearch很详细的入门文章 

https://www.jianshu.com/p/930c803a4ebd

你可能感兴趣的:(报错)