当前位置: 首页 > news >正文

如何在自己的服务器上搭建微网站鸿科经纬教网店运营推广

如何在自己的服务器上搭建微网站,鸿科经纬教网店运营推广,鹰潭网站商城建设,网站备案登录密码找回文章目录 pom.xml1创建索引2.创建索引并设置settings信息3.创建索引并设置mapping信息4.删除索引库5.给未设置mapping的索引设置mapping elasticsearch版本7.10.2#xff0c;要求java客户端与之相匹配#xff0c;推荐Springboot版本是2.3以上版本 依赖配置使用的是JUnit 5要求java客户端与之相匹配推荐Springboot版本是2.3以上版本 依赖配置使用的是JUnit 5由artifactIdspring-boot-starter-test/artifactId提供支持而Before注解是JUnit 4中的注解。在JUnit 5中应该使用BeforeEach来代替Before。 替换注解 将所有的Before注解替换为BeforeEach。 确保你的测试类使用了JUnit 5的相关注解如TestJUnit 5中的Test注解位于org.junit.jupiter.api.Test。 确保测试类正确配置 确保你的测试类上没有使用JUnit 4的RunWith注解。 如果使用了Spring的测试支持确保类上有SpringBootTest或其他相关的Spring测试注解。 更新测试方法 确认所有的测试方法都使用了JUnit 5的Test注解。 pom.xml project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.3.2.RELEASE/versionrelativePath/ !-- lookup parent from repository --/parentartifactIdchubemall-search/artifactIdpackagingjar/packagingnamechubemall-search/nameurlhttp://maven.apache.org/urlpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingjava.version1.8/java.versionspring-cloud.versionGreenwich.SR3/spring-cloud.versionelasticsearch.version7.10.2/elasticsearch.version/propertiesdependencies !-- dependency-- !-- groupIdjunit/groupId-- !-- artifactIdjunit/artifactId-- !-- version3.8.1/version-- !-- scopetest/scope-- !-- /dependency--!--引入common公共模块--dependencygroupIdcom.xd.cubemall/groupIdartifactIdcubemall-common/artifactIdversion0.0.1-SNAPSHOT/version/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!-- dependency-- !-- groupIdorg.springframework.boot/groupId-- !-- artifactIdspring-boot-starter-data-elasticsearch/artifactId-- !-- /dependency--dependencygroupIdorg.elasticsearch.client/groupIdartifactIdelasticsearch-rest-high-level-client/artifactIdversion7.10.2/version/dependency/dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion${spring-cloud.version}/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagement /project 1创建索引 步骤 1.创建一个RestHightLevelClient对象相当于和服务端建立连接 2.使用client的索引管理的对象indices()返回索引管理对象 package com.xd.cubemall.es;import org.apache.http.HttpHost; import org.elasticsearch.client.IndicesClient; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.indices.CreateIndexRequest; import org.elasticsearch.client.indices.CreateIndexResponse; import org.junit.jupiter.api.Test;/*** 索引管理*/ public class IndexManager {Testpublic void createIndex() throws Exception {//创建一个client对象RestHighLevelClient client new RestHighLevelClient(RestClient.builder(new HttpHost(1.1.1.1,9200),new HttpHost(2.2.2.2,9200),new HttpHost(3.3.3.3,9200)));//获得索引管理对象IndicesClient indicesClient client.indices();//两个参数//1.创建索引请求对象CreateIndexRequest request new CreateIndexRequest(hello);//2.请求选项使用默认值。配置请求头主要用于认证。CreateIndexResponse response indicesClient.create(request, RequestOptions.DEFAULT);System.out.println(response);} } 2.创建索引并设置settings信息 CreateIndexRequest对象中设置settings即可 package com.xd.cubemall.es;import org.apache.http.HttpHost; import org.elasticsearch.client.IndicesClient; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.indices.CreateIndexRequest; import org.elasticsearch.client.indices.CreateIndexResponse; import org.elasticsearch.common.settings.Settings; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;/*** 索引管理*/ public class IndexManager {private RestHighLevelClient client;BeforeEachpublic void init() {//创建一个client对象client new RestHighLevelClient(RestClient.builder(new HttpHost(1.1.1.1,9200),new HttpHost(2.2.2.2,9200),new HttpHost(3.3.3.3,9200)));}Testpublic void createIndex() throws Exception {//获得索引管理对象IndicesClient indicesClient client.indices();//两个参数//1.创建索引请求对象CreateIndexRequest request new CreateIndexRequest(hello);//2.请求选项使用默认值。配置请求头主要用于认证。CreateIndexResponse response indicesClient.create(request, RequestOptions.DEFAULT);//显示结果System.out.println(response);}Testpublic void createIndex2() throws Exception {CreateIndexRequest request new CreateIndexRequest(hello1).settings(Settings.builder().put(number_of_shards, 5).put(number_of_replicas,1).build());System.out.println(Client is null: (client null));System.out.println(Request is null: (request null));client.indices().create(request,RequestOptions.DEFAULT);}} 3.创建索引并设置mapping信息 {properties:{id:{type:long},title:{type:text,analyzer:ik_smart,store:true},content:{type:text,analyzer:ik_smart,store:true} } }Testpublic void createIndex3() throws Exception {XContentBuilder mappings XContentFactory.jsonBuilder().startObject().startObject(properties).startObject(id).field(type,long).endObject().startObject(title).field(type,text).field(analyzer,ik_smart).field(store,true).endObject().startObject(content).field(type,text).field(analyzer,ik_smart).field(store,true).endObject().endObject().endObject();CreateIndexRequest request new CreateIndexRequest(hello2).settings(Settings.builder().put(number_of_shards, 5).put(number_of_replicas,1).build()).mapping(mappings);client.indices().create(request, RequestOptions.DEFAULT);}4.删除索引库 DeleteIndexRequest对象其中包含索引库的名称即可 indices().delete(request) Testpublic void deleteIndex() throws Exception {client.indices().delete(new DeleteIndexRequest(hello),RequestOptions.DEFAULT);}5.给未设置mapping的索引设置mapping Testpublic void putMappings() throws Exception {String mappings {\n \t\properties\:{\n \t\t\id\:{\n \t\t\t\type\:\long\\n \t\t},\n \t\t\title\:{\n \t\t\t\type\:\text\,\n \t\t\t\analyzer\:\ik_smart\,\n \t\t\t\store\:true\n \t\t},\n \t\t\content\:{\n \t\t\t\type\:\text\,\n \t\t\t\analyzer\:\ik_smart\,\n \t\t\t\store\:true\n \t\t}\t\t\n \t}\n };PutMappingRequest request new PutMappingRequest(hello1).source(mappings, XContentType.JSON);client.indices().putMapping(request,RequestOptions.DEFAULT);}
http://www.hkea.cn/news/14584815/

相关文章:

  • 建设网站的费用如何入账中细软做的网站
  • 苏州网站建设公司书生商友电商网站后台报价
  • 微网站和手机网站怎么删除网站的死链
  • 张家港建设银行网站网站开发飞沐
  • 网站的需求分析怎么写网站负责人核验照
  • 有账号和密码怎么进公司网站后台vs2012 网站开发
  • 做营销型网站 公司实施网站推广的最终目的
  • 长春市房产交易中心官网如何做网站的seo优化
  • 中国建设企业网站官网直播app下载汅api免费下载
  • python毕业设计做网站常州转化率网站建设公司怎么样
  • 泉州手机网站制作国外网站推广宣传
  • 网络营销做女鞋的网站设计鄂州手机网站建设
  • 长沙营销网站建站公司辽宁建设工程信息网查询系统
  • 网站开发岗位之间的关联水务行业国企门户网站建设
  • 河南网站建设设计价格外贸网站模
  • 那些网站可以接私活做阿里巴巴网站制作
  • 服装怎么做网站推广手机网站建设地址
  • 新公司注册工商核名系统南通网站建设推广优化
  • 网站上动画视频怎么做安徽建设工程信息网实名制怎么解聘
  • 花卉网站建设策划方案下载新华社app
  • 只做女性的网站深圳网站建设公司哪家最好
  • 安庆网站制作wordpress汉化免费企业主题
  • 网站建设一般收费北京建网站哪家公司好
  • 网站开发制作心得松岗网站设计
  • 网站建设 英文怎么说江苏seo策略
  • 网站维护的要求网站建设管理工作情况报告
  • 好的建筑设计网站网站建设 维护费用
  • 天水做网站的电子商务网站建设 臧良运 好不好
  • 网站建设和数据库维护做导航网站成本
  • wordpress开发企业网站济南高端网站设计