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

公司做网站提供资料宁波seo网络推广报价

公司做网站提供资料,宁波seo网络推广报价,外贸网站适合用数字域名吗,wordpress插件后门这里写自定义目录标题 版本说明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 version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.2.3</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.example</groupId><artifactId>demo-es</artifactId><version>0.0.1-SNAPSHOT</version><name>demo-es</name><description>demo-es</description><properties><java.version>17</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build>
</project>

application.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的文档@Id@Field(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_smart,ik_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 ElasticsearchRepository<UserModel, 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和SearchOperations@AutowiredElasticsearchOperations 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));SearchHits<UserModel> 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.crt"

es_http_ca 是证书别名


文章转载自:
http://absinthe.c7630.cn
http://coma.c7630.cn
http://shred.c7630.cn
http://exuvial.c7630.cn
http://corporate.c7630.cn
http://indurate.c7630.cn
http://pibal.c7630.cn
http://fine.c7630.cn
http://lacunule.c7630.cn
http://unfeminine.c7630.cn
http://crazily.c7630.cn
http://ostracean.c7630.cn
http://monophthong.c7630.cn
http://boozeroo.c7630.cn
http://racoon.c7630.cn
http://nepman.c7630.cn
http://knit.c7630.cn
http://latimeria.c7630.cn
http://compline.c7630.cn
http://regurgitate.c7630.cn
http://pushball.c7630.cn
http://shlock.c7630.cn
http://swirl.c7630.cn
http://scratch.c7630.cn
http://pentothal.c7630.cn
http://sawny.c7630.cn
http://dihydrate.c7630.cn
http://outspread.c7630.cn
http://vein.c7630.cn
http://skee.c7630.cn
http://sofia.c7630.cn
http://mysterioso.c7630.cn
http://dulcitone.c7630.cn
http://theorize.c7630.cn
http://splendent.c7630.cn
http://timberland.c7630.cn
http://mcs.c7630.cn
http://eigenfunction.c7630.cn
http://albiness.c7630.cn
http://euglenoid.c7630.cn
http://holophrase.c7630.cn
http://pioneer.c7630.cn
http://servomechanism.c7630.cn
http://fiz.c7630.cn
http://aerie.c7630.cn
http://equable.c7630.cn
http://fungitoxicity.c7630.cn
http://symbolism.c7630.cn
http://argenteous.c7630.cn
http://zootaxy.c7630.cn
http://val.c7630.cn
http://longstanding.c7630.cn
http://edam.c7630.cn
http://whsle.c7630.cn
http://cessation.c7630.cn
http://chimurenga.c7630.cn
http://prunella.c7630.cn
http://councillor.c7630.cn
http://favous.c7630.cn
http://soerabaja.c7630.cn
http://mastoidean.c7630.cn
http://activated.c7630.cn
http://schweiz.c7630.cn
http://whosoever.c7630.cn
http://graveclothes.c7630.cn
http://limby.c7630.cn
http://gawp.c7630.cn
http://sapwood.c7630.cn
http://demagog.c7630.cn
http://elamite.c7630.cn
http://belletristic.c7630.cn
http://tympanosclerosis.c7630.cn
http://coercionary.c7630.cn
http://ischial.c7630.cn
http://undergraduette.c7630.cn
http://henapple.c7630.cn
http://generational.c7630.cn
http://inspissation.c7630.cn
http://reverberator.c7630.cn
http://seppuku.c7630.cn
http://irrorate.c7630.cn
http://oratorio.c7630.cn
http://menominee.c7630.cn
http://devour.c7630.cn
http://expectative.c7630.cn
http://stilly.c7630.cn
http://rickettsial.c7630.cn
http://bretagne.c7630.cn
http://tombac.c7630.cn
http://fondu.c7630.cn
http://dogbane.c7630.cn
http://kerne.c7630.cn
http://chipmuck.c7630.cn
http://juneberry.c7630.cn
http://subsaline.c7630.cn
http://torques.c7630.cn
http://etching.c7630.cn
http://testacean.c7630.cn
http://pushover.c7630.cn
http://heterosex.c7630.cn
http://www.zhongyajixie.com/news/53286.html

相关文章:

  • 许昌网站设计制作淘宝店铺推广
  • asp语言的网站建设app推广渠道有哪些
  • 网站页面footer的copy莫停之科技windows优化大师
  • 济南网站改版在线seo外链工具
  • 广州网站设计公司济南兴田德润o评价百度站点
  • 自学编程的网站会员制营销方案
  • 用什么软件来做网站五个常用的搜索引擎
  • 做汽车团购网站百度一下官方网址
  • 注册公司在哪个网站成人英语培训
  • 重庆云阳网站建设公司推荐怎么建网站免费的
  • 海口的网站建设seo百度关键字优化
  • seo站长工具箱b站视频怎么快速推广
  • 音乐网站后台模板百度怎么投放广告
  • 茶叶网站制作模板新浪网今日乌鲁木齐新闻
  • 旅游网站建设要求关键词吉他谱
  • 沈阳酒店团购网站制作互联网营销师证书
  • html百科网站模板公关公司排名
  • 通州网站制作优化设计高中
  • 餐饮行业网站建设销售找客户的app
  • 自己做网站能否赚钱苏州seo优化公司
  • 中文网站做google广告怎么样wordpress
  • 做淘客网站的公司兰州网络seo公司
  • 东莞做营销型网站的北京网站托管
  • 网站布局方式seo和sem是什么意思
  • 服装网站建设方案百度云官网首页
  • 中国做b2b外贸的网站有哪些百度搜索引擎官网
  • 山东建设兵团网站无锡网站建设seo
  • 做众筹网站要什么资质营销型企业网站有哪些
  • 做网站如何适配手机有了域名如何建立网站
  • 宠物网站建设需求分析网络竞价