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信号,更能在各类复杂环境中展现出卓越的性能。它的设计灵感来源于海洋中的礁鲨,象征着力量…...

RocketMQ延迟消息机制
两种延迟消息 RocketMQ中提供了两种延迟消息机制 指定固定的延迟级别 通过在Message中设定一个MessageDelayLevel参数,对应18个预设的延迟级别指定时间点的延迟级别 通过在Message中设定一个DeliverTimeMS指定一个Long类型表示的具体时间点。到了时间点后…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互
物理引擎(Physics Engine) 物理引擎 是一种通过计算机模拟物理规律(如力学、碰撞、重力、流体动力学等)的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互,广泛应用于 游戏开发、动画制作、虚…...

CMake基础:构建流程详解
目录 1.CMake构建过程的基本流程 2.CMake构建的具体步骤 2.1.创建构建目录 2.2.使用 CMake 生成构建文件 2.3.编译和构建 2.4.清理构建文件 2.5.重新配置和构建 3.跨平台构建示例 4.工具链与交叉编译 5.CMake构建后的项目结构解析 5.1.CMake构建后的目录结构 5.2.构…...

对WWDC 2025 Keynote 内容的预测
借助我们以往对苹果公司发展路径的深入研究经验,以及大语言模型的分析能力,我们系统梳理了多年来苹果 WWDC 主题演讲的规律。在 WWDC 2025 即将揭幕之际,我们让 ChatGPT 对今年的 Keynote 内容进行了一个初步预测,聊作存档。等到明…...

BCS 2025|百度副总裁陈洋:智能体在安全领域的应用实践
6月5日,2025全球数字经济大会数字安全主论坛暨北京网络安全大会在国家会议中心隆重开幕。百度副总裁陈洋受邀出席,并作《智能体在安全领域的应用实践》主题演讲,分享了在智能体在安全领域的突破性实践。他指出,百度通过将安全能力…...
laravel8+vue3.0+element-plus搭建方法
创建 laravel8 项目 composer create-project --prefer-dist laravel/laravel laravel8 8.* 安装 laravel/ui composer require laravel/ui 修改 package.json 文件 "devDependencies": {"vue/compiler-sfc": "^3.0.7","axios": …...

Reasoning over Uncertain Text by Generative Large Language Models
https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829 1. 概述 文本中的不确定性在许多语境中传达,从日常对话到特定领域的文档(例如医学文档)(Heritage 2013;Landmark、Gulbrandsen 和 Svenevei…...
Linux C语言网络编程详细入门教程:如何一步步实现TCP服务端与客户端通信
文章目录 Linux C语言网络编程详细入门教程:如何一步步实现TCP服务端与客户端通信前言一、网络通信基础概念二、服务端与客户端的完整流程图解三、每一步的详细讲解和代码示例1. 创建Socket(服务端和客户端都要)2. 绑定本地地址和端口&#x…...

Netty从入门到进阶(二)
二、Netty入门 1. 概述 1.1 Netty是什么 Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty是一个异步的、基于事件驱动的网络应用框架,用于…...
【前端异常】JavaScript错误处理:分析 Uncaught (in promise) error
在前端开发中,JavaScript 异常是不可避免的。随着现代前端应用越来越多地使用异步操作(如 Promise、async/await 等),开发者常常会遇到 Uncaught (in promise) error 错误。这个错误是由于未正确处理 Promise 的拒绝(r…...