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

电子商务网站推广方案直播平台推荐

电子商务网站推广方案,直播平台推荐,电子商务网站建设 故宫官网,互联网网站建设趋势这里写自定义目录标题 版本说明spring boot POM依赖application.yml配置新建模型映射Repository简单测试完整项目文件目录结构windows下elasticsearch安装配置 版本说明 官网说明 本文使用最新的版本 springboot: 3.2.3 spring-data elasticsearch: 5.2.3 elasticsearch: 8.1… 这里写自定义目录标题 版本说明spring boot POM依赖application.yml配置新建模型映射Repository简单测试完整项目文件目录结构windows下elasticsearch安装配置 版本说明 官网说明 本文使用最新的版本 springboot: 3.2.3 spring-data elasticsearch: 5.2.3 elasticsearch: 8.11.4 elasticsearch下载链接https://www.elastic.co/cn/downloads/past-releases#elasticsearch 最新版可能不兼容以spring官网为准 spring boot POM依赖 ?xml version1.0 encodingUTF-8? 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 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.2.3/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.example/groupIdartifactIddemo-es/artifactIdversion0.0.1-SNAPSHOT/versionnamedemo-es/namedescriptiondemo-es/descriptionpropertiesjava.version17/java.version/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-elasticsearch/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdconfigurationexcludesexcludegroupIdorg.projectlombok/groupIdartifactIdlombok/artifactId/exclude/excludes/configuration/plugin/plugins/build /projectapplication.yml配置 使用https必须配置username 和 password spring:elasticsearch:uris: https://localhost:9200username: elasticpassword: 123456新建模型映射 package com.example.demoes.es.model;import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType;Data AllArgsConstructor NoArgsConstructor Document(indexName user) // user 是elasticsearch的索引名称新版本的elasticsearch没有了type的概念 public class UserModel { // 每一个UserModel对应一个elasticsearch的文档IdField(name id, type FieldType.Integer)Integer id;// FieldType.Keyword 不可分词Field(name name, type FieldType.Keyword)String name;// index false 不建立索引Field(name age, type FieldType.Integer, index false)Integer age;// FieldType.Text 可分词ik_smartik_max_word 是ik分词器对中文分词友好需要另外安装Field(name address, type FieldType.Text, searchAnalyzer ik_smart, analyzer ik_max_word)String address;} Repository spring data的repository方便操作类似jpa的操作 继承ElasticsearchRepository自带一些基础的操作方法 package com.example.demoes.es.repo;import com.example.demoes.es.model.UserModel; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;// UserModel 模型映射 Integer ID的类型 public interface ESUserRepository extends ElasticsearchRepositoryUserModel, Integer {}简单测试 package com.example.demoes;import com.example.demoes.es.model.UserModel; import com.example.demoes.es.repo.ESUserRepository; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.elasticsearch.core.*; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.query.Criteria; import org.springframework.data.elasticsearch.core.query.CriteriaQuery;SpringBootTest class DemoEsApplicationTests {AutowiredESUserRepository esUserRepository;// 以下三个是 spring-boot-starter-data-elasticsearch 自动配置的 elasticsearch 操作 Bean// 1. DocumentOperations 文档操作AutowiredDocumentOperations documentOperations;// 2. SearchOperations 查询操作AutowiredSearchOperations searchOperations;// 3. ElasticsearchOperations elasticsearch 通用的操作,包括DocumentOperations和SearchOperationsAutowiredElasticsearchOperations elasticsearchOperations;Testvoid contextLoads() {}Testpublic void testIndex() {// 获取索引操作IndexOperations indexOperations elasticsearchOperations.indexOps(UserModel.class);// 查看索引映射关系System.out.println(indexOperations.getMapping());// 输出索引名称System.out.println(indexOperations.getIndexCoordinates().getIndexName());}/*** 添加文档*/Testpublic void testAdd() {esUserRepository.save(new UserModel(1, 张三, 18, 北京朝阳));esUserRepository.save(new UserModel(2, 李四, 19, 北京朝阳));esUserRepository.save(new UserModel(3, 王五, 20, 北京朝阳));esUserRepository.save(new UserModel(4, 赵六, 21, 北京朝阳));esUserRepository.save(new UserModel(5, 马六, 22, 北京朝阳));esUserRepository.save(new UserModel(6, 孙七, 23, 北京朝阳));esUserRepository.save(new UserModel(7, 吴八, 24, 北京朝阳));esUserRepository.save(new UserModel(8, 郑九, 25, 北京朝阳));// 查询所有esUserRepository.findAll().forEach(System.out::println);}/*** 更新文档*/Testpublic void testUpdate() {// 按id更新IndexCoordinates indexCoordinates elasticsearchOperations.indexOps(UserModel.class).getIndexCoordinates();documentOperations.update(new UserModel(1, 张三, 60, 北京朝阳), indexCoordinates);}/*** 删除文档*/Testpublic void testDelete() {documentOperations.delete(String.valueOf(8), UserModel.class);}/*** 查询文档*/Testpublic void testSearch() {CriteriaQuery query new CriteriaQuery(new Criteria(id).is(2));SearchHitsUserModel searchHits searchOperations.search(query, UserModel.class);for (SearchHit searchHit : searchHits.getSearchHits()){UserModel user (UserModel) searchHit.getContent();System.out.println(user);}}}完整项目文件目录结构 windows下elasticsearch安装配置 直接解压修改配置文件解压目录/config/elasticsearch.yml # 集群名称 cluster.name: el-cluster # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # #node.name: node-1 # 节点名称 node.name: el-node-1# 数据和日志存储路径默认安装位置path.data: D:/module/elasticsearch-8.11.4/datapath.logs: D:/module/elasticsearch-8.11.4/logs# 访问限制0.0.0.0代表所有IP都可以访问localhost也可以 network.host: 0.0.0.0 # 访问端口 默认9200 http.port: 9200# 安全配置以下的配置第一次启动时自动生成也可以不配置 #----------------------- BEGIN SECURITY AUTO CONFIGURATION ----------------------- # # The following settings, TLS certificates, and keys have been automatically # generated to configure Elasticsearch security features on 21-03-2024 01:32:15 # # --------------------------------------------------------------------------------# Enable security features 不使用https时设为false xpack.security.enabled: truexpack.security.enrollment.enabled: true# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents 不使用https时设为false xpack.security.http.ssl:enabled: truekeystore.path: certs/http.p12# Enable encryption and mutual authentication between cluster nodes xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: certs/transport.p12truststore.path: certs/transport.p12 # Create a new cluster with the current node only # Additional nodes can still join the cluster later cluster.initial_master_nodes: [el-node-1]#----------------------- END SECURITY AUTO CONFIGURATION ------------------------- 第一次启动会在控制台打印密码用户名默认elastic 修改密码的话不要关闭控制台另外开启一个控制台进入elastic search安装目录下的bin目录使用以下命令修改 -i 是交互式的意思没有的话会随机生成密码无法自定义。 输入命令回车然后输入两次密码就行了 elasticsearch-reset-password --username elastic -i使用keytool工具将ca证书导入到jdk。 keytool是jdk自带的工具使用以下命令 keytool -importcert -cacerts -alias es_http_ca -file elasticsearch安装路径\config\certs\http_ca.crtes_http_ca 是证书别名
http://www.w-s-a.com/news/267636/

相关文章:

  • 粉色的网站绍兴市建设局网站
  • 个人网站的基本风格是wordpress 模板选择
  • 南昌专业做网站公司有哪些广州市住房城乡建设部门户网站
  • 福州网站建设团队淘宝联盟网站怎么建设
  • 福州企业网站建站模板国内黑色风格的网站
  • 好看的网站首页设计android移动开发
  • 域名注册完成后如何做网站域名 删除 wordpress
  • wordpress xml导入大小东莞seo优化方案
  • 网站建设效益网站销售怎么做的
  • 利用网站空间做代理设计方案的格式范文
  • 无锡建设工程质量监督网站遵义做手机网站建设
  • 衡阳商城网站制作ps做网站首页规范尺寸
  • 微信网站应用开发营销推广的方案
  • 广州做网站商城的公司制作一个app的完整流程
  • 湖南城乡建设厅网站163注册企业邮箱
  • 做网站怎么调整图片间距织梦做的网站如何去掉index
  • 凡科网免费建站步骤及视频网页设计基础教程第二版课后答案
  • 建设一个旅游网站毕业设计企业网站要更新文章吗
  • 做网站需要简介中山网站设计公司
  • 网站怎么做导航栏微信公众号官网登录
  • 1_ 掌握网站开发的基本流程 要求:熟悉网站开发与设计的基本流程.电子商城网站开发
  • 百度网站怎么建设河北省工程造价信息网官网
  • 阿里云网站模板网页设计的合适尺寸是多少
  • 做小程序和做网站哪个好让别人做网站推广需要多少钱
  • 做外贸的几个网站查询网域名解析
  • 酒泉如何做百度的网站seo研究中心好客站
  • 网站设计建设平台户县做网站
  • 一元云购网站开发wordpress博客空间
  • 深圳高端网站建设公司排名如何搭建局域网服务器
  • 照片管理网站模板高端网站开发哪家好