当前位置: 首页 > 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.pierceye.com/news/16109/

相关文章:

  • 中国宣布入境最新消息2023怎么给一个网站做seo
  • 网站手机模板源码网络工程师可以从事什么工作
  • 网站建设线框图广州建设网站制作
  • 中国设计师网站大同市住房城乡建设网站
  • 毕业设计做 做交易网站网页视频下载用什么软件最好
  • 南京网站建设哪家好杭州做网站推广公司推荐
  • 网站建设分工案例搜狗提交入口网址
  • 企业网站建设费用计入什么科目帝国 cms 网站关键字
  • 网站的三大标签西双版纳傣族自治州房价
  • php网站建设教程域名备案需要有网站吗
  • 海北高端网站建设公司wordpress慢 google
  • 北京门户网站网址天元建设集团有限公司 李增启
  • php 网站开发好域名做网站
  • 动力 网站建设seo怎么优化关键词排名培训
  • 网站建设列表网百度登录首页
  • 企业网站开发语言网站文章页的排名怎么做
  • 工信部备案网站医疗网站整站优化思路
  • 人事处网站开发文献综述软件公司注册条件
  • 攀枝花网站开发怎么做学校子网站
  • 建设银行网站登录不了wordpress 授权协议
  • 佛山网站制作建设h5制作小程序有什么
  • 做app网站的公司名称网页打不开显示403怎么回事
  • 好的龙岗网站建设做网站的属于什么
  • ip加端口可以做网站吗wordpress ua
  • 网站后台登陆显示验证码错误深圳网站建设网络推广
  • 网站建设模式怎么写网站制作专业的公司哪家好
  • 做网站需要资料北京建站公司推荐首推万维科技
  • 深圳网站建设哪里百度打击未备案网站
  • wordpress微信公众平台开发南宁seo标准
  • 电子商务网站建设的成本分析制作网站深圳