Mr_sswen 2020-12-01 19:31 采纳率: 50%
浏览 173
已结题

ssm配置elasticsearch问题

jdk1.8 + Myeclipse + spring4.0.2 + elasticsearch6.5.4(本地已能部署运行) 如下版本依赖

<dependency>
		    <groupId>org.elasticsearch</groupId>
		    <artifactId>elasticsearch</artifactId>
		    <version>6.5.4</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-elasticsearch -->
		<dependency>
		    <groupId>org.springframework.data</groupId>
		    <artifactId>spring-data-elasticsearch</artifactId>
		    <version>3.2.6.RELEASE</version>
		</dependency>
		
		<dependency>
	        <groupId>org.elasticsearch.client</groupId>
	        <artifactId>transport</artifactId>
	        <version>6.5.4</version>
	    </dependency>

xml配置文件加这三段就会出错,去掉就能正常运行

<!-- 搜索DAO 扫描 -->
    <elasticsearch:repositories base-package="com.esDao" elasticsearch-template-ref="elasticsearchTemplate"/>
 
    <!-- 配置Client -->
    <elasticsearch:transport-client id="client" cluster-nodes="127.0.0.1:9200"/>
 
    <!-- 配置搜索模板  -->
    <bean id="elasticsearchTemplate"
          class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
        <constructor-arg name="client" ref="client" />
    </bean>

esDao下:

User:

package com.esDao;

import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import com.fasterxml.jackson.annotation.JsonFormat;

@Document(indexName = "user_db", type = "user_table")
public class User{
    @Id
    @Field(type = FieldType.Keyword)
    private String userId;

    @Field(type= FieldType.Keyword)
    private String account; 

    @Field(type= FieldType.Keyword)
    private String userName;

    @Field(type= FieldType.Keyword)
    private String idCard; 

    @Field(type = FieldType.Date,
            format = DateFormat.custom,
            pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime; 
    //DOTO
    //get和set方法
    //toString()方法
}

UserRepository:

package com.esDao;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface UserRepository extends ElasticsearchRepository<User, String> {
    void Main();
}

 项目启动后报错信息(大致意思应该是版本不对):

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;

真心求解,please

  • 写回答

8条回答 默认 最新

  • benpaodexin_l 2020-12-02 10:40
    关注

    少jar吧

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制