推荐一个非常好的博客: 点我

// 测试使用docker下启动的es不管用, 在linux下或者windows下运行的es可用

// 进一步测试docker下启动的es链接时, 开启嗅探也链接不上, 异常和spring下一样

// 查阅资料后有说是因为vmware网卡的原因, 但因为目前只有一台电脑, 没有做进一步测试

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.</modelVersion>
<groupId>com.iwhere</groupId>
<artifactId>ElasticSearchLearn</artifactId>
<version>0.0.-SNAPSHOT</version>
<packaging>war</packaging> <properties>
<junit.version>4.12</junit.version>
<spring.version>4.3..RELEASE</spring.version>
<mybatis.version>3.2.</mybatis.version>
<mybatis.spring.version>1.2.</mybatis.spring.version>
<mybatis.paginator.version>1.2.</mybatis.paginator.version>
<mysql.version>5.1.</mysql.version>
<druid.version>1.0.</druid.version>
<httpclient.version>4.3.</httpclient.version>
<jstl.version>1.2</jstl.version>
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.0</jsp-api.version>
<joda-time.version>2.5</joda-time.version>
<commons-lang3.version>3.3.</commons-lang3.version>
<commons-io.version>1.3.</commons-io.version>
<commons-net.version>3.3</commons-net.version>
<pagehelper.version>3.4.-fix</pagehelper.version>
<commons-fileupload.version>1.3.</commons-fileupload.version>
<jedis.version>2.7.</jedis.version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency> <!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>com.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
<version>${mybatis.paginator.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency> <!-- MySql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency> <!-- 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp-api.version}</version>
<scope>provided</scope>
</dependency> <!-- es包 -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.</version>
</dependency> <!-- spring整合es -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>2.0..RELEASE</version>
</dependency> <!-- junitTest -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3..RELEASE</version>
</dependency> <!-- fastJson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.1.</version>
</dependency> <!-- slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources> <plugins>
<!-- 锁定jdk版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
<version>3.5.</version>
<configuration>
<!-- 项目启动端口 -->
<port></port>
<!-- 配置项目发布路径 :/表示根路径,类似tomcat的ROOT目录 -->
<path>/</path>
</configuration>
</plugin>
</plugins> </build> </project>

spring.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd"> <!-- 开启扫描-->
<context:component-scan base-package="com.iwhere.controller"></context:component-scan> <context:property-placeholder location="classpath:source/*.properties"/> <mvc:default-servlet-handler/> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean> <!-- 加载其他配置文件 -->
<!-- <import resource="classpath:spring/applicationContext-*.xml"/> -->
<import resource = "classpath:spring/elasticsearch.xml" /> </beans>

es 的 applicationContext-elasticsearch.xml的配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <elasticsearch:repositories base-package="com.iwhere.springES" /> <!-- <elasticsearch:transport-client id="client" cluster-nodes="${esserver.cluster.server}:9300"
cluster-name="${esserver.cluster.name}" /> -->
<elasticsearch:transport-client id="client" cluster-nodes="192.168.50.37:9300" cluster-name="wenbronk_escluster" /> <bean name="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="client" />
</bean> <elasticsearch:repositories base-package="org.springframework.data.elasticsearch.repositories"></elasticsearch:repositories> </beans>

elasticsearch.properites

esserver.cluster.name = wenbronk_escluster
esserver.cluster.server = 192.168.50.37

spring整合elasticsearch之环境搭建的更多相关文章

  1. SSM(Spring+SpringMVC+Mybatis)框架环境搭建(整合步骤)(一)

    1. 前言 最近在写毕设过程中,重新梳理了一遍SSM框架,特此记录一下. 附上源码:https://gitee.com/niceyoo/jeenotes-ssm 2. 概述 在写代码之前我们先了解一下 ...

  2. 【转载】Maven+druid+MyBatis+Spring+Oracle+Dubbo开发环境搭建

    原地址:http://blog.csdn.net/wp1603710463/article/details/48247817#t16 Maven+druid+MyBatis+spring+Oracle ...

  3. 基于Maven的Spring + Spring MVC + Mybatis的环境搭建

    基于Maven的Spring + Spring MVC + Mybatis的环境搭建项目开发,先将环境先搭建起来.上次做了一个Spring + Spring MVC + Mybatis + Log4J ...

  4. 第一章 Spring整体框架和环境搭建

    1.Spring 的整体架构 Spring框架主要由7大模块组成,它们提供了企业级开发需要的所有功能,而且每个模块都可以单独使用,也可以和其他模块组合使用,灵活且方便的部署可以使开发的程序更加简洁灵活 ...

  5. [转]ssm整合1(环境搭建)

    1 MyEclipse+Tomcat+MAVEN+SVN项目完整环境搭建http://blog.csdn.net/zhshulin/article/details/307798732 apache-m ...

  6. 整合SSM框架环境搭建

    知识要求 MySQL相关操作 Maven操作 Mybatis.Spring.SpringMVC三个框架基本操作 JavaWeb等知识 搭建环境 MySQL 8.0 Mybatis 3.5.2 使用c3 ...

  7. elasticsearch + hive环境搭建

    一.环境介绍: elasticsearch:2.3.1 hive:0.12 二.环境搭建 2.1 首先获取elasticsearc-hadoop的jar包 链接地址:http://jcenter.bi ...

  8. 转载 Elasticsearch开发环境搭建(Eclipse\MyEclipse + Maven)

    概要: 1.使用Eclipse搭建Elasticsearch详情参考下面链接 2.Java Elasticsearch 配置 3.ElasticSearch Java Api(一) -添加数据创建索引 ...

  9. Spring集成Quarz开发环境搭建

    第一步,搭建Spring相关的环境,参照:http://www.cnblogs.com/dyh004/p/4645572.html 第二步,下载Quartz相关的压缩文件,解压,下载地址:http:/ ...

随机推荐

  1. CxGrid导出Excel时清除颜色的设置

    CxGrid导出Excel时清除颜色的设置 (2011-04-25 16:33:23) 转载▼ 标签: it 分类: Delphi http://www.radxe.com/?p=170 cxgrid ...

  2. Android adb shell data目录,Permission denied

    Android adb shell进入data目录,Permission denied 权限被拒绝 在shell里面输入su root,去申请root权限,注意:有小部分手机是需要点击授权,再次执行c ...

  3. 【WinRT】TransitionDemo

    折腾了一晚,将 WinRT 里的所有 Transition 做了一个小 Demo,用于演示各个 Transition 的效果. PS:NavigationThemeTransition 请参考:htt ...

  4. SQL SERVER 2008 附加数据库出现只读问题。

    问题描述 在附加数据库时出现的图片:   解决办法 步骤一,修改文件夹的 1.打开该数据库文件存放的目录或数据库文件的属性窗口,选择"属性"菜单->选择"安全&qu ...

  5. DropDownList切换选择,服务器控件Repeater未更新

    将EnableViewState属性设置为false,这样禁止服务器控件使用视图状态,也就是禁止发送给浏览器HEML中的缓存副本, 每次都会使用新数据. 一旦页面的控件很多,频繁的传递控件状态值对网络 ...

  6. .net core api Post请求

    POST请求: 1.请求类型:Content-Type:application/json,参数:json字符串 后台接收参数: 1)([FromBody]UserInfo user)必须以对象形式接收 ...

  7. python小数的进位与舍去

    一.基础知识准备 ​ 奇进偶舍,又称为四舍六入五成双规则.银行进位法(Banker's Rounding),是一种计数保留法,是一种数值修约规则.从统计学的角度,"奇进偶舍"比&q ...

  8. 重新设置Linux文件共享密码..

    今天同事把我主机踹倒了,鼠键都没反应,于是我在Linux运行的情况下强制重启了下电脑. 启动完了VMware后Linux重启,正常使用.后来我想起来有快照功能 之前也没用到过,于是就点了一下刚开始安装 ...

  9. 使用git工具将本地电脑上的代码上传至GitHub

    本文教你如果使用git工具将本地电脑上的代码上传至GitHub 1.安装git工具 安装git链接 2.使用git工具上传自己的代码到GitHub中 安装完git工具之后,我们会得到两个命令行工具,一 ...

  10. 【codeforces 24D】损坏的机器人

    题目大意:有一只坏了的机器人站在一个n∗m的网格里,初始位置在(x,y).现在每个单位时间内它会随机选左右下三个方向走,如果它随机的方向会走出网格就不会往这个方向走.当然这个机器人也可能原地停留一个单 ...