资源简介
spring spingmvc 集成elasticSearch 5.5.x版本 ,基本的增删改查.完成
代码片段和文件信息
package com.atguigu.springmvc.entities;
import java.net.InetAddress;
import java.util.Properties;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
@Component
public class Client implements FactoryBean InitializingBean DisposableBean {
private String clusterNodes;
private String clusterName;
private Boolean clientTransportSniff = true;
private Boolean clientIgnoreClusterName = Boolean.FALSE;
private String clientPingTimeout = “5s“;
private String clientNodesSamplerInterval = “5s“;
private TransportClient client;
private Properties properties;
static final String COLON = “:“;
static final String COMMA = ““;
@Override
public void destroy() throws Exception {
try {
if (client != null) {
client.close();
}
} catch (final Exception e) {
}
}
@Override
public TransportClient getobject() throws Exception {
return client;
}
@Override
public Class getobjectType() {
return TransportClient.class;
}
@Override
public boolean isSingleton() {
return false;
}
@Override
public void afterPropertiesSet() throws Exception {
buildClient();
}
protected void buildClient() throws Exception {
client = new PreBuiltTransportClient(settings());
System.out.println(“连接开始“);
String port = “9300“;
System.out.println();
Assert.hasText(port “[Assertion failed] missing port in ‘clusterNodes‘“);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(“localhost“) Integer.valueOf(port)));
client.connectedNodes();
}
private Settings settings() {
if (properties != null) {
return Settings.builder().put(properties).build();
}
return Settings.builder()
.put(“cluster.name“ clusterName)
.put(“client.transport.sniff“ clientTransportSniff)
.put(“client.transport.ignore_cluster_name“ clientIgnoreClusterName)
.put(“client.transport.ping_timeout“ clientPingTimeout)
.put(“client.transport.nodes_sampler_interval“ clientNodesSamplerInterval)
.build();
}
public void
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4483 2017-07-20 09:25 springmvc-1\.classpath
文件 1428 2017-07-19 17:03 springmvc-1\.project
文件 503 2014-12-07 09:33 springmvc-1\.settings\.jsdtscope
文件 57 2017-07-20 09:24 springmvc-1\.settings\org.eclipse.core.resources.prefs
文件 736 2017-07-20 09:25 springmvc-1\.settings\org.eclipse.jdt.core.prefs
文件 90 2017-07-19 17:03 springmvc-1\.settings\org.eclipse.m2e.core.prefs
文件 569 2017-07-20 09:21 springmvc-1\.settings\org.eclipse.wst.common.component
文件 345 2014-12-07 09:33 springmvc-1\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2014-12-07 09:33 springmvc-1\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2014-12-07 09:33 springmvc-1\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 50 2017-07-20 09:21 springmvc-1\.settings\org.eclipse.wst.validation.prefs
文件 453 2014-12-07 09:48 springmvc-1\.springBeans
文件 508 2017-07-20 09:14 springmvc-1\build\classes\applicationContext.xm
文件 1016 2017-07-20 09:12 springmvc-1\build\classes\com\atguigu\springmvc\entities\Address.class
文件 338 2017-07-20 09:15 springmvc-1\build\classes\com\atguigu\springmvc\entities\ESTransportClient.class
文件 2598 2017-07-20 09:12 springmvc-1\build\classes\com\atguigu\springmvc\entities\User.class
文件 757 2017-07-20 09:12 springmvc-1\build\classes\com\atguigu\springmvc\handlers\HelloWorld.class
文件 7596 2017-07-20 09:12 springmvc-1\build\classes\com\atguigu\springmvc\handlers\SpringMVCTest.class
文件 1520 2017-07-20 09:12 springmvc-1\build\classes\com\atguigu\springmvc\views\HelloView.class
文件 46 2014-12-13 20:53 springmvc-1\build\classes\i18n.properties
文件 46 2014-12-13 20:53 springmvc-1\build\classes\i18n_en_US.properties
文件 60 2014-12-13 20:54 springmvc-1\build\classes\i18n_zh_CN.properties
文件 3643 2017-07-20 13:55 springmvc-1\pom.xm
文件 619 2017-07-20 12:13 springmvc-1\src\applicationContext.xm
文件 4794 2017-07-20 12:13 springmvc-1\src\com\atguigu\springmvc\entities\Client.java
文件 470 2017-07-20 13:37 springmvc-1\src\com\atguigu\springmvc\entities\Student.java
文件 3609 2017-07-20 17:21 springmvc-1\src\com\atguigu\springmvc\handlers\HelloWorld.java
文件 949 2017-07-20 17:18 springmvc-1\src\com\atguigu\springmvc\service\ElSerarchService.java
文件 6962 2017-07-20 17:25 springmvc-1\src\com\atguigu\springmvc\service\Impl\ElSerarchServiceImpl.java
文件 626 2017-07-19 16:27 springmvc-1\src\com\atguigu\springmvc\views\HelloView.java
............此处省略83个文件信息
- 上一篇:基于web的公交查询系统
- 下一篇:unity 无限循环列表
相关资源
- springboot+rabbitmq项目demo(亲测可正常运
- springboot整合RabbitMQ实现延时队列的两
- 关于Spring MVC项目maven中通过fileupload上
- The Research on Smart Drill-in Fluid Design
- Spring-Data-Redis2.0+Spring5
- 2017年-传智播客-张志君老师-SpringBoo
- springboot+mybatis整合实现注册登录
-
spring-fr
amework-5.0.2.RELEASE 源码包 - 基于web的图书馆运营系统
- springboot+webflux+mongodb+freemarker
- springboot整合activiti完整demo
- SpringBoot实战(第4版)清晰版.pdf.zip
- SpringBoot 中文文档
- springboot+jpa+thymeleaf实现增删改查分页
- es(elasticsearch)整合SpringCloudSpringBo
- Springboot日志开启SLF4J过程解析
- 原银在线信贷平台概要设计说明书v
- springcloud 微服务(全套视频)
- springCloud教学视频
- springboot全套教程2018年2.0版本
- 官网springboot项目
- Spring Boot中自定义注解结合AOP实现主备
- flowable整合Spring
- Spring Security架构以及源码详析
- Research on Forecasting Method of Urban Water
- SpringBoot+Mybatis+前后台隔离技术,完整
- Spring Boot技术栈博客企业前后端2018
- springboot从入门到精通视频教程课程源
- Research on carbon emissions of Industry in tr
- Research of Catalyst Preparing 14-Naphthoquino
评论
共有 条评论