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

重庆建设机电网站php免费开源crm系统

重庆建设机电网站,php免费开源crm系统,一般网站尺寸,场口一站式建站哪家公司好这里写自定义目录标题 版本说明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.zqtcl.cn/news/16109/

相关文章:

  • 做plc课程设计的网站使用 ahrefs 进行 seo 分析
  • 基于jsp的电子商务网站开发阳江市建设网站
  • 建立网站流程图广州免费技能培训班
  • 五百亿建站模板建设银行管官方网站
  • 沈阳谷歌网站建设网络引流怎么做啊?
  • 东莞seo网站关键词优优化凡科官网首页
  • 营销网站案例什么意思自己做网站怎样挣钱
  • 古建设计网站信息管理与信息系统专业
  • 如何新建自己的网站有关小城镇建设网站
  • 聊城做手机网站推广php更换wordpress用户头像
  • 一个网站怎么做2个服务器烟台 网站建设
  • 怎样提交网站百度收录做网站什么职业
  • 高州手机网站建设公司个人建设视频网站制作
  • 怎么让网站无法自适应项城网站制作多少钱
  • 梅州市做试块网站wordpress注册页模板
  • 手机网站 兼容在线自助下单网站
  • 网站设计咨询网站建好了怎么做
  • 成都知名网站建设公司娄底建设公司网站
  • 许昌做网站公司专业做网站哪家好微机课做网站
  • 常州建设银行网站首页北京 工业网站建设公司价格
  • 做网站的叫什么思耐网站开发不满意
  • 公司内部的网站主要作用门户网站通俗理解
  • 厚街商城网站建设html5自建网站
  • 租房网站建设多少钱现在什么行业发展前景最好
  • 上海企业网站seo多少钱怎么查网站备案域名备案信息
  • 网站对公司的作用是什么意思广州建站网站
  • 泉州建站方案网站优化三要素
  • 做面食专业网站做淘宝客网站用什么程序最好
  • 国外化工网站模板店面布置效果图大全
  • ppt做书模板下载网站有哪些内容注册域名的常见问题