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

做网站的协议做织梦网站的心得体会

做网站的协议,做织梦网站的心得体会,中山建设工程招聘信息网站,app定制开发报价这里写自定义目录标题 版本说明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.pierceye.com/news/584090/

相关文章:

  • 郑州企业网站优化多少钱百度竞价排名价格
  • js特效做的好的网站什么专业是做网站
  • 淄川响应式网站建设网站在国内服务器在国外
  • 施工企业市场经营工作思路及措施个人如何优化网站有哪些方法
  • 怎么做一个盈利网站义乌创博网络科技有限公司
  • 学校网站建设代码不重名的建筑公司名字
  • 网站开发模块的需求海外销售平台有哪些
  • 前端和后端的区别工资郑州网站优化怎样做
  • 小程序模板平台有哪些网站优化包括哪些内容
  • 免费建网站的好的移动端网站模板下载
  • 青岛网站优化排名视频源网站怎么做
  • 做网站找我二级学院网站建设方案
  • 知名网站建设公司 北京近期网络营销的热点事件
  • 网站开发产品经理网站例子
  • 动态静态结合网站网站做404是什么意思
  • 注册域名的网站网站建设的具体步骤
  • 行业网站分类自建站排名
  • 网站备案 登陆安徽省住房和城乡建设厅网站领域
  • 做个网站需要多少钱.网站建设合同注意事项
  • 中国诚信建设网站在线代码生成器
  • 长沙企业网站建设团队目前网络最好的挣钱平台
  • 国家建设工程安全质量监督网站友情链接网
  • 适合html初学者做的网站中卫网站推广软件
  • 一个vps主机放两个网站 速度怎么做发卡网站
  • 海米云网站建设网站开发 去哪里找页面
  • 天津做网站优化的公司新手学做网站优化
  • 万网怎么上传网站wordpress google字体 360
  • 为什么建设的网站有时候访问慢6紫金优化网站制作
  • 如何在公司系统建网站广州短视频seo哪家好
  • 电气网站开发福安网站定制