ES升级--04--SpringBoot整合Elasticsearch
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
- SpringBoot整合Elasticsearch
- 1.建立项目
- 2.Maven 依赖
- [ES 官方网站:https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.8/index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.8/index.html)
- 3. pom配置
- 4.证书文件elastic-certificates.p12 拷贝
- 证书文件elastic-certificates.p12需拷贝到所有ES节点对应的目录下
- 5.配置类 ElasticsearchConfig
- SecureRestClientConfig
- 6.nacos配置参数
- 7.测试
- 1.TransportClient
- 2.ElasticsearchTemplate
- 3.RestHighLevelClient
- 4.ElasticsearchRestTemplate
SpringBoot整合Elasticsearch
1.建立项目


2.Maven 依赖
进入到 ES 官方网站
ES 官方网站:https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.8/index.html

- 可以看到有低级和 高级的 Rest Client

3. pom配置
基于 springboot 2.1.7.RELEASE
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency><!-- ES --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId></dependency><dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-elasticsearch</artifactId><version>3.2.9.RELEASE</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>6.8.23</version><exclusions><exclusion><groupId>org.elasticsearch.client</groupId><artifactId>transport</artifactId></exclusion><exclusion><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-client</artifactId></exclusion><exclusion><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>transport</artifactId><version>6.8.23</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-client</artifactId><version>6.8.23</version></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>6.8.23</version></dependency><dependency><groupId>org.elasticsearch.plugin</groupId><artifactId>transport-netty4-client</artifactId><version>6.8.23</version></dependency><!-- Elasticsearch客户端依赖版本升级到6.8.32 新增x-pack依赖--><dependency><groupId>org.elasticsearch.client</groupId><artifactId>x-pack-transport</artifactId><version>6.8.23</version></dependency>
4.证书文件elastic-certificates.p12 拷贝
证书文件elastic-certificates.p12需拷贝到所有ES节点对应的目录下
- 注意:只需创建一次证书并将其复制到所有节点。

5.配置类 ElasticsearchConfig
支持x-pack 密码验证
/*** ES 配置 -----Elasticsearch 6.8.23* 通过实现配置配,初始化安全Elasticsearch客户端对象,包括ElasticsearchTemplate和RestHighLevelClient两者客户端类* 支持x-pack 密码验证*/@Slf4j
@Configuration
public class SecureElasticsearchConfig {//用户名 elastic@Value("${elasticsearch.xpack.username}")private String xpackUsername = "elastic";//用户密码@Value("${elasticsearch.xpack.password}")private String xpackrPassword;//证书路径 "/home/data/es"@Value("${elasticsearch.xpack.kspath}")private String certPath;//证书密码 ""@Value("${elasticsearch.xpack.kspwd}")private String certPassword;//集群名@Value("${elasticsearch.master.cluster-name}")private String masterClusterName;//节点名@Value("${elasticsearch.master.clusterNodes}")private String clusterNodes;//ip@Value("${elasticsearch.master.address}")private String masterAddress;//端口@Value("${elasticsearch.master.port}")private Integer masterPort;// // es 连接超时时间
// private int connectTimeOut;
// // es socket 连接超时时间
// private int socketTimeOut;
// // es 请求超时时间
// private int connectionRequestTimeOut;
// // es 最大连接数
// private int maxConnectNum;
// // es 每个路由的最大连接数
// private int maxConnectNumPerRoute;/***集群配置*/private Settings settings() {Settings.Builder builder = Settings.builder();//基础配置builder.put("cluster.name", masterClusterName);builder.put("xpack.security.user", xpackUsername+ ":" + xpackrPassword);// Keystore 配置builder.put("xpack.security.transport.ssl.keystore.path", certPath);builder.put("xpack.security.transport.ssl.keystore.password", certPassword);// Truststore 配置builder.put("xpack.security.transport.ssl.truststore.path", certPath);builder.put("xpack.security.transport.ssl.truststore.password", certPassword);// 验证模式配置builder.put("xpack.security.transport.ssl.verification_mode", "certificate");// 启用 X-Pack 安全功能builder.put("xpack.security.enabled", true);builder.put("xpack.security.transport.ssl.enabled", true);return builder.build();}/*** 初始化安全TransportClient类*/@Beanpublic TransportClient transportClient() throws Exception {//本地测试用// certPath="D:\\cdms\\es\\elastic-certificates.p12";log.info(">>>>>>>>>>> SecureElasticsearchConfig TransportClient 开始初始化");Settings settings = settings();PreBuiltXPackTransportClient client = new PreBuiltXPackTransportClient(settings);client.addTransportAddress(new TransportAddress(InetAddress.getByName(masterAddress), masterPort));return client;}/***初始化安全ElasticsearchTemplate类* 基于 spring-boot-starter-data*/@Beanpublic ElasticsearchTemplate elasticsearchTemplate(@Autowired TransportClient transportClient) throws Exception {log.info(">>>>>>>>>>> SecureElasticsearchConfig ElasticsearchTemplate 开始初始化");ElasticsearchTemplate secureElasticsearchTemplate;try {secureElasticsearchTemplate = new ElasticsearchTemplate(transportClient);return secureElasticsearchTemplate;} catch (Exception e) {log.error("SecureElasticsearchConfig 初始化ElasticsearchTemplate报错: ", e.getMessage());throw e;}}/*** 初始化安全RestHighLevelClient类* 只支持http 端口: 9200*/@Beanpublic RestHighLevelClient restHighLevelClient() {log.info(">>>>>>>>>>> SecureElasticsearchConfig RestHighLevelClient 开始初始化");final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();credentialsProvider.setCredentials(AuthScope.ANY,new UsernamePasswordCredentials(xpackUsername, xpackrPassword));RestClientBuilder builder = RestClient.builder(new HttpHost(masterAddress,9200)).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {@Overridepublic HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) {return httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);}});RestHighLevelClient client = new RestHighLevelClient(builder);// // 连接延时配置
// builder.setRequestConfigCallback(requestConfigBuilder -> {
// requestConfigBuilder.setConnectTimeout(connectTimeOut);
// requestConfigBuilder.setSocketTimeout(socketTimeOut);
// requestConfigBuilder.setConnectionRequestTimeout(connectionRequestTimeOut);
// return requestConfigBuilder;
// });
// // 连接数配置
// builder.setHttpClientConfigCallback(httpClientBuilder -> {
// httpClientBuilder.setMaxConnTotal(maxConnectNum);
// httpClientBuilder.setMaxConnPerRoute(maxConnectNumPerRoute);
// httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
// return httpClientBuilder;
// });return client;}/***初始化安全ElasticsearchRestTemplate类* 基于 spring-boot-starter-data*/@BeanElasticsearchRestTemplate elasticsearchRestTemplate(@Autowired RestHighLevelClient restHighLevelClient) {log.info(">>>>>>>>>>> SecureElasticsearchConfig ElasticsearchRestTemplate 开始初始化");return new ElasticsearchRestTemplate(restHighLevelClient);}}
SecureRestClientConfig
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;import java.util.Arrays;/*** ES 配置 -----Elasticsearch 6.8.23* 通过实现配置配,初始化安全 RestHighLevelClient,ElasticsearchRestTemplate客户端类* 支持x-pack 密码验证*/
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "spring.elasticsearch.rest")
public class SecureRestClientConfig {//端口 ip@Setterprivate String[] hosts = new String[]{};//用户名 elastic@Setterprivate String xpackusername;//用户密码@Setterprivate String xpackpassword;// // es 连接超时时间
// private int connectTimeOut;
// // es socket 连接超时时间
// private int socketTimeOut;
// // es 请求超时时间
// private int connectionRequestTimeOut;
// // es 最大连接数
// private int maxConnectNum;
// // es 每个路由的最大连接数
// private int maxConnectNumPerRoute;/*** 初始化安全RestHighLevelClient类* 只支持http 端口: 9200*/@Beanpublic RestHighLevelClient restHighLevelClient() {log.info(">>>>>>>>>>> RestClientConfig RestHighLevelClient 开始初始化");HttpHost[] httpHosts = Arrays.stream(hosts).map(x -> {String[] hostInfo = x.split(":");return new HttpHost(hostInfo[0], Integer.parseInt(hostInfo[1]));}).toArray(HttpHost[]::new);log.info("elasticsearch hosts: ", Arrays.toString(httpHosts));final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(xpackusername, xpackpassword));RestClientBuilder builder = null;try {builder = RestClient.builder(httpHosts).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {@Overridepublic HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) {return httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);}});} catch (Exception e) {log.error("RestClientConfig 初始化RestHighLevelClient报错: ", e.getMessage());throw new RuntimeException(e);}// // 连接延时配置
// builder.setRequestConfigCallback(requestConfigBuilder -> {
// requestConfigBuilder.setConnectTimeout(connectTimeOut);
// requestConfigBuilder.setSocketTimeout(socketTimeOut);
// requestConfigBuilder.setConnectionRequestTimeout(connectionRequestTimeOut);
// return requestConfigBuilder;
// });
// // 连接数配置
// builder.setHttpClientConfigCallback(httpClientBuilder -> {
// httpClientBuilder.setMaxConnTotal(maxConnectNum);
// httpClientBuilder.setMaxConnPerRoute(maxConnectNumPerRoute);
// httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
// return httpClientBuilder;
// });RestHighLevelClient client = new RestHighLevelClient(builder);return client;}@Bean(name = {"elasticsearchOperations", "elasticsearchTemplate"})ElasticsearchRestTemplate elasticsearchRestTemplate(@Autowired RestHighLevelClient restHighLevelClient) {return new ElasticsearchRestTemplate(restHighLevelClient);}
}
6.nacos配置参数
elasticsearch:xpack:username: elasticpassword: escdmskspath: /home/data/eskspwd: master:cluster-name: gz-java-test-laasclusterNodes: master-test-laasaddress: 192.168.2.89port: 9300
7.测试
1.TransportClient
@Autowiredprivate TransportClient transportClient;@Testpublic void createIndex_transportClient() {String indexName="lass_test_transportclient";try {CreateIndexRequest request = new CreateIndexRequest(indexName);// 可以在此处添加更多设置,例如映射 (mapping) 和设置 (settings)CreateIndexResponse response = transportClient.admin().indices().create(request).actionGet();if (response.isAcknowledged()) {System.out.println("Index created successfully: " + indexName);} else {System.out.println("Index creation failed: " + indexName);}} catch (Exception e) {System.err.println("Error creating index: " + e.getMessage());}}@Testpublic void addDocuments_transportClient() {String indexName = "lass_test_transportclient";try {String json1 = "{" +"\"user\":\"kimchy\"," +"\"postDate\":\"2013-01-30\"," +"\"message\":\"trying out Elasticsearch\"" +"}";IndexResponse response1 = transportClient.prepareIndex(indexName, "_doc").setSource(json1, XContentType.JSON).get();// if (response1.status() == RestStatus.CREATED) {
// System.out.println("Document 1 indexed successfully.");
// } else {
// System.out.println("Failed to index Document 1.");
// }String json2 = "{" +"\"user\":\"Tom\"," +"\"postDate\":\"2024-01-30\"," +"\"message\":\"lass升级 transportClient \"" +"}";transportClient.prepareIndex(indexName, "_doc").setSource(json2, XContentType.JSON).get();} catch (Exception e) {System.err.println("Error adding documents: " + e.getMessage());}}@Testpublic void deleteIndex_transportClient() {String indexName = "lass_test_transportclient";try {DeleteIndexRequest request = new DeleteIndexRequest(indexName);AcknowledgedResponse response = transportClient.admin().indices().delete(request).actionGet();if (response.isAcknowledged()) {System.out.println("Index deleted successfully: " + indexName);} else {System.out.println("Failed to delete index: " + indexName);}} catch (Exception e) {System.err.println("Error deleting index: " + e.getMessage());}}
GET lass_test_transportclient/_search
{"query":{"match_all" : {}}
}

2.ElasticsearchTemplate
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Document(indexName = "lass_test_people",type = "_doc",shards = 1,replicas = 1)
public class People {@Idprivate String id;// 整个name不被分词,切不创建索引// Keyword表示不被分词@Field(type= FieldType.Keyword,index = false)private String name;// address被ik分词// Text类型的属性才能被分词@Field(type = FieldType.Text)private String address;@Field(type = FieldType.Long,index = false)private int age;}
@Autowiredprivate ElasticsearchTemplate elasticsearchTemplate;@Testpublic void createIndex_elasticsearchTemplate() {//根据实体类创建索引,boolean result1 = elasticsearchTemplate.createIndex(People.class);System.out.println(result1);//将索引放到软件里面boolean results = elasticsearchTemplate.putMapping(People.class);}@Testpublic void addDocuments_elasticsearchTemplate() {People peo = new People();peo.setId("123");peo.setName("张三");peo.setAddress("北京市海淀区回龙观东大街");peo.setAge(18);IndexQuery query = new IndexQuery();query.setObject(peo);String result = elasticsearchTemplate.index(query);System.out.println(result);}@Testpublic void bulk(){List<IndexQuery> list = new ArrayList<>();// IndexQuery多行写法IndexQuery indexQuery = new IndexQuery();indexQuery.setObject(new People("1", "王五", "北京东城", 12));list.add(indexQuery);// IndexQuery 连缀写法list.add(new IndexQueryBuilder().withObject(new People("2", "赵六", "北京西城", 13)).build());list.add(new IndexQueryBuilder().withObject(new People("3", "吴七", "北京昌平", 14)).build());elasticsearchTemplate.bulkIndex(list);}@Testpublic void deletee_elasticsearchTemplate() {boolean result = elasticsearchTemplate.deleteIndex(People.class);System.out.println(result);}

3.RestHighLevelClient
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Document(indexName = "lass_test_student",type = AudienceEsConst.DOC, createIndex = false, useServerConfiguration = true)
public class Student {@Idprivate String id;// 整个name不被分词,切不创建索引// Keyword表示不被分词@Field(type= FieldType.Keyword,index = false)private String name;// address被ik分词// Text类型的属性才能被分词@Field(type = FieldType.Text)private String address;@Field(type = FieldType.Long,index = false)private int age;}
@Autowiredprivate RestHighLevelClient restHighLevelClient;@Testpublic void createIndex_restHighLevelClient() throws IOException {String indexName = "lass_test_resthighlevelclient";XContentBuilder builder = XContentFactory.jsonBuilder();builder.startObject();{builder.field("user", "zhangSan");builder.timeField("postDate", new Date());builder.field("message", "laas 升级 RestHighLevelClient ");}builder.endObject();IndexRequest request = new IndexRequest(indexName, "doc").source(builder);IndexResponse indexResponse = restHighLevelClient.index(request, RequestOptions.DEFAULT);if (indexResponse.status() == RestStatus.CREATED) {System.out.println("Document 1 indexed successfully.");} else {System.out.println("Failed to index Document 1.");}}@Testpublic void addDocuments_restHighLevelClient() {String indexName = "lass_test_resthighlevelclient";try {Map<String, Object> jsonMap = new HashMap<>();jsonMap.put("user", "李四");jsonMap.put("postDate", new Date());jsonMap.put("message", "laas 升级 RestHighLevelClient ");IndexRequest indexRequest = new IndexRequest(indexName,"doc").source(jsonMap);IndexResponse indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);if (indexResponse.status() == RestStatus.CREATED) {System.out.println("Document 1 indexed successfully.");} else {System.out.println("Failed to index Document 1.");}} catch (Exception e) {System.err.println("Error adding documents: " + e.getMessage());}}@Testpublic void deletee_restHighLevelClient() {String indexName = "lass_test_resthighlevelclient";boolean result = elasticsearchTemplate.deleteIndex(indexName);System.out.println(result);}
4.ElasticsearchRestTemplate
@Autowiredprivate ElasticsearchRestTemplate restTemplate;@Testpublic void createIndex_restTemplate() {//根据实体类创建索引,boolean result1 = restTemplate.createIndex(Student.class);System.out.println(result1);//将索引放到软件里面boolean results = restTemplate.putMapping(Student.class);}@Testpublic void addDocuments_restTemplate() {Student student = new Student();student.setId("123");student.setName("张三");student.setAddress("北京市海淀区回龙观东大街");student.setAge(18);IndexQuery query = new IndexQuery();query.setObject(student);String result = restTemplate.index(query);System.out.println(result);}@Testpublic void bulk_restTemplate(){List<IndexQuery> list = new ArrayList<>();// IndexQuery多行写法IndexQuery indexQuery = new IndexQuery();indexQuery.setObject(new Student("1", "王五", "北京东城", 12));list.add(indexQuery);// IndexQuery 连缀写法list.add(new IndexQueryBuilder().withObject(new Student("2", "赵六", "北京西城", 13)).build());list.add(new IndexQueryBuilder().withObject(new Student("3", "吴七", "北京昌平", 14)).build());restTemplate.bulkIndex(list);}@Testpublic void deletee_restTemplate() {boolean result = restTemplate.deleteIndex(Student.class);System.out.println(result);}相关文章:
ES升级--04--SpringBoot整合Elasticsearch
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 SpringBoot整合Elasticsearch1.建立项目2.Maven 依赖[ES 官方网站:https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.8/index.html](…...
eclipse如何debug
步骤1:双击显示行数的数字来设置断点 步骤2:点击debug 步骤3:在弹出的窗口点击switch 步骤4:就可以调试了,右边是查看数据的,点击上面的图标进行下一步 步骤5:退出debug 步骤6:…...
无人售货机零售业务成功指南:从市场分析到创新策略
在科技驱动的零售新时代,无人售货机作为一种便捷购物解决方案,正逐步兴起,它不仅优化了消费者体验,还显著降低了人力成本,提升了运营效能。开展这项业务前,深入的市场剖析不可或缺,需聚焦消费者…...
开源代码分享(32)-基于改进多目标灰狼算法的冷热电联供型微电网运行优化
参考文献: [1]戚艳,尚学军,聂靖宇,等.基于改进多目标灰狼算法的冷热电联供型微电网运行优化[J].电测与仪表,2022,59(06):12-1952.DOI:10.19753/j.issn1001-1390.2022.06.002. 1.问题背景 针对冷热电联供型微电网运行调度的优化问题,为实现节能减排的目…...
7、架构-架构的安全性
即使只限定在“软件架构设计”这个语境下,系统安全仍然是一 个很大的话题。我们谈论的计算机系统安全,不仅仅是指“防御系统 被黑客攻击”这样狭隘的安全,还至少应包括(不限于)以下这些问 题的具体解决方案。 认证&am…...
LeetCode题练习与总结:路径总和Ⅱ--113
一、题目描述 给你二叉树的根节点 root 和一个整数目标和 targetSum ,找出所有 从根节点到叶子节点 路径总和等于给定目标和的路径。 叶子节点 是指没有子节点的节点。 示例 1: 输入:root [5,4,8,11,null,13,4,7,2,null,null,5,1], target…...
Java复数计算
复数在数学、科学或者工程领域是很常用的,可以通过调用Apache Commons Math库来完成,也可以自己手撸。 一、使用Apache Commons Math库 这个库有多个版本,在写这篇文章时,它的最新版是2022年12月19日的4.0-beta1,构建…...
MySQL-事务日志
事务的隔离性由 锁机制 实现 事务的原子性、一致性、隔离性 由事务的 redo日志 和 undo 日志来保证 redo log 称为 重做日志,提供再写入操作,恢复提交事务修改的页操作,用来保证事务的持久性。undo log 称为 回滚日志,回滚行记录…...
PySide6 GUI 学习笔记——常用类及控件使用方法(常用类坐标点QPoint)
控件是PySide设计好的能承载用户输入、输出的小窗体,将多个控件有机整合,能形成用户所需要的界面。而每一个控件,都有属于自己的属性、方法、信号、槽函数和事件(event),且控件与控件之间又有继承关系。 G…...
算法练习——字符串
一确定字符串是否包含唯一字符 1.1涉及知识点 c的输入输出语法 cin>>s; cout<<"NO"; 如何定义字符串 切记:在[]中必须加数字——字符串最大长度,不然编译不通过 char s[101]; 如何获取字符串长度 char s[101];cin>>s;i…...
Flutter 中的 SliverOverlapInjector 小部件:全面指南
Flutter 中的 SliverOverlapInjector 小部件:全面指南 Flutter 是一个功能丰富的 UI 框架,由 Google 开发,允许开发者使用 Dart 语言构建跨平台的移动、Web 和桌面应用。在 Flutter 的滚动视图系统中,SliverOverlapInjector 是一…...
7个Python爬虫入门小案例
大家好,随着互联网的快速发展,数据成为了新时代的石油。Python作为一种高效、易学的编程语言,在数据采集领域有着广泛的应用。本文将详细讲解Python爬虫的原理、常用库以及实战案例,帮助读者掌握爬虫技能。 一、爬虫原理 爬虫&a…...
linux 利用 ~$() 构造数字
2024.6.1 题目 <?php //flag in 12.php error_reporting(0); if(isset($_GET[x])){$x $_GET[x];if(!preg_match("/[a-z0-9;|#\"%&\x09\x0a><.,?*\-\\[\]]/i", $x)){system("cat ".$x.".php");} }else{highlight_file(__F…...
七大获取免费https的方式
想要实现https访问最简单有效的的方法就是安装SSL证书。只要证书正常安装上以后,浏览器就不会出现网站不安全提示或者访问被拦截的情况。下面我来教大家怎么去获取免费的SSL证书,又如何安装证书实现https访问。 一、选择免费SSL证书提供商 有多家机构提…...
JVM(Java虚拟机)笔记
面试常见: 请你谈谈你对JVM的理解?java8虚拟机和之前的变化更新?什么是OOM,什么是栈溢出StackOverFlowError? 怎么分析?JVM的常用调优参数有哪些?内存快照如何抓取?怎么分析Dump文件?谈谈JVM中,类加载器你的认识…...
秒杀基本功能开发(显示商品列表和商品详情)
文章目录 1.数据库表设计1.商品表2.秒杀商品表3.修改一下秒杀时间为今天到明天 2.pojo和vo编写1.com/sxs/seckill/pojo/Goods.java2.com/sxs/seckill/pojo/SeckillGoods.java3.com/sxs/seckill/vo/GoodsVo.java 3.Mapper编写1.GoodsMapper.java2.GoodsMapper.xml3.分别编写Seck…...
centos 记录用户登陆ip和执行命令
centos 记录用户登陆ip和执行命令 在/etc/profile 文件末尾添加如下代码: #!/bin/bash USER_IPwho -u am i 2>/dev/null | awk {print $NF} | sed -e s/[()]//g HISTDIR/usr/share/.history if [ -z "$USER_IP" ]; then USER_IPhostname fi…...
JZ2440笔记:DM9000C网卡驱动
在厂家提供的dm9dev9000c.c上修改, 1、注释掉#ifdef MODULE #endif 2、用模块化函数修饰入口出口函数 3、在dm9000c_init入口函数,增加iobase (int)ioremap(0x20000000,1024);irq IRQ_EINT7; 4、一路进入,在dmfe_probe1中注释掉if((db…...
【数据结构】二叉树:简约和复杂的交织之美
专栏引入: 哈喽大家好,我是野生的编程萌新,首先感谢大家的观看。数据结构的学习者大多有这样的想法:数据结构很重要,一定要学好,但数据结构比较抽象,有些算法理解起来很困难,学的很累…...
信号稳定,性能卓越!德思特礁鲨系列MiMo天线正式发布!
作者介绍 礁鲨系列天线,以其独特的外观设计和强大的性能,成为德思特Panorama智能天线家族的最新成员。这款天线不仅稳定提供5G、WIFI和GNSS信号,更能在各类复杂环境中展现出卓越的性能。它的设计灵感来源于海洋中的礁鲨,象征着力量…...
网络编程(Modbus进阶)
思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…...
浅谈 React Hooks
React Hooks 是 React 16.8 引入的一组 API,用于在函数组件中使用 state 和其他 React 特性(例如生命周期方法、context 等)。Hooks 通过简洁的函数接口,解决了状态与 UI 的高度解耦,通过函数式编程范式实现更灵活 Rea…...
基于FPGA的PID算法学习———实现PID比例控制算法
基于FPGA的PID算法学习 前言一、PID算法分析二、PID仿真分析1. PID代码2.PI代码3.P代码4.顶层5.测试文件6.仿真波形 总结 前言 学习内容:参考网站: PID算法控制 PID即:Proportional(比例)、Integral(积分&…...
cf2117E
原题链接:https://codeforces.com/contest/2117/problem/E 题目背景: 给定两个数组a,b,可以执行多次以下操作:选择 i (1 < i < n - 1),并设置 或,也可以在执行上述操作前执行一次删除任意 和 。求…...
PL0语法,分析器实现!
简介 PL/0 是一种简单的编程语言,通常用于教学编译原理。它的语法结构清晰,功能包括常量定义、变量声明、过程(子程序)定义以及基本的控制结构(如条件语句和循环语句)。 PL/0 语法规范 PL/0 是一种教学用的小型编程语言,由 Niklaus Wirth 设计,用于展示编译原理的核…...
Caliper 配置文件解析:config.yaml
Caliper 是一个区块链性能基准测试工具,用于评估不同区块链平台的性能。下面我将详细解释你提供的 fisco-bcos.json 文件结构,并说明它与 config.yaml 文件的关系。 fisco-bcos.json 文件解析 这个文件是针对 FISCO-BCOS 区块链网络的 Caliper 配置文件,主要包含以下几个部…...
【JavaWeb】Docker项目部署
引言 之前学习了Linux操作系统的常见命令,在Linux上安装软件,以及如何在Linux上部署一个单体项目,大多数同学都会有相同的感受,那就是麻烦。 核心体现在三点: 命令太多了,记不住 软件安装包名字复杂&…...
RNN避坑指南:从数学推导到LSTM/GRU工业级部署实战流程
本文较长,建议点赞收藏,以免遗失。更多AI大模型应用开发学习视频及资料,尽在聚客AI学院。 本文全面剖析RNN核心原理,深入讲解梯度消失/爆炸问题,并通过LSTM/GRU结构实现解决方案,提供时间序列预测和文本生成…...
dify打造数据可视化图表
一、概述 在日常工作和学习中,我们经常需要和数据打交道。无论是分析报告、项目展示,还是简单的数据洞察,一个清晰直观的图表,往往能胜过千言万语。 一款能让数据可视化变得超级简单的 MCP Server,由蚂蚁集团 AntV 团队…...
SiFli 52把Imagie图片,Font字体资源放在指定位置,编译成指定img.bin和font.bin的问题
分区配置 (ptab.json) img 属性介绍: img 属性指定分区存放的 image 名称,指定的 image 名称必须是当前工程生成的 binary 。 如果 binary 有多个文件,则以 proj_name:binary_name 格式指定文件名, proj_name 为工程 名&…...
