(十一)Springboot+ElasticSearch8整合

2023-10-30

前言

在 Elasticsearch7.15版本之后,Elasticsearch官方将它的高级客户端 RestHighLevelClient标记为弃用状态。推出全新的 Java API客户端 Elasticsearch Java API Client,该客户端也将在 Elasticsearch8.0及以后版本中成为官方推荐使用的客户端。

1.导入ES依赖

        <!--es搜索-->
		<dependency>
			<groupId>co.elastic.clients</groupId>
			<artifactId>elasticsearch-java</artifactId>
			<version>8.1.3</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.13.3</version>
		</dependency>

出现报错 java.lang.NoClassDefFoundError: jakarta/json/JsonException导入下面依赖

    <dependency>
		<groupId>jakarta.json</groupId>
		<artifactId>jakarta.json-api</artifactId>
		<version>2.0.1</version>
	</dependency>

2.增加配置文件

// 配置的前缀
@ConfigurationProperties(prefix = "elasticsearch") 
@Configuration
public class ESClientConfig {

	/**
	 * 多个IP逗号隔开
	 */
	@Setter
	private String hosts;

	/**
	 * 同步方式
	 * 
	 * @return
	 */
	@Bean
	public ElasticsearchClient elasticsearchClient() {
		HttpHost[] httpHosts = toHttpHost();
		// Create the RestClient 
		RestClient restClient = RestClient.builder(httpHosts).build();
		// Create the transport with a Jackson mapper
		RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
		// create the API client
		return new ElasticsearchClient(transport);
	}

	/**
	 * 异步方式
	 * 
	 * @return
	 */
	@Bean
	public ElasticsearchAsyncClient elasticsearchAsyncClient() {
		HttpHost[] httpHosts = toHttpHost();
		RestClient restClient = RestClient.builder(httpHosts).build();
		RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
		return new ElasticsearchAsyncClient(transport);
	}

	/**
	 * 解析配置的字符串hosts,转为HttpHost对象数组
	 *
	 * @return
	 */
	private HttpHost[] toHttpHost() {
		if (!StringUtils.hasLength(hosts)) {
			throw new RuntimeException("invalid elasticsearch configuration. elasticsearch.hosts不能为空!");
		}

		// 多个IP逗号隔开
		String[] hostArray = hosts.split(",");
		HttpHost[] httpHosts = new HttpHost[hostArray.length];
		HttpHost httpHost;
		for (int i = 0; i < hostArray.length; i++) {
			String[] strings = hostArray[i].split(":");
			httpHost = new HttpHost(strings[0], Integer.parseInt(strings[1]), "http");
			httpHosts[i] = httpHost;
		}

		return httpHosts;
	}

}

增加配置文件配置es访问的地址和端口

elasticsearch:
  hosts: 172.16.5.10:9200

3.测试

注入 ElasticsearchClient添加studyes索引

@RunWith(SpringRunner.class)
@SpringBootTest(classes = DatacenterApplication.class)
@Slf4j
public class ESTest {

    @Autowired
    private ElasticsearchClient client;

    @Test
    public void createidx() throws IOException {
        CreateIndexResponse response = client.indices().create(c -> c.index("studyes"));
        log.info("createIndex方法,acknowledged={}", response.acknowledged());
    }
}

可以看到 studyes 索引已经添加
在这里插入图片描述

索引操作

接口

public interface IndexService {

	/**
	 * 新建索引,指定索引名称
	 * 
	 * @param name
	 * @throws IOException
	 */
	void createIndex(String name) throws IOException;

	/**
	 * 创建索引,指定索引名称和setting和mapping
	 *
	 * @param name
	 *            - 索引名称
	 * @param settingFn
	 *            - 索引参数
	 * @param mappingFn
	 *            - 索引结构
	 * @throws IOException
	 */
	void createIndex(String name, Function<IndexSettings.Builder, ObjectBuilder<IndexSettings>> settingFn,
			Function<TypeMapping.Builder, ObjectBuilder<TypeMapping>> mappingFn) throws IOException;

	/**
	 * 删除索引
	 *
	 * @param name
	 * @throws IOException
	 */
	void deleteIndex(String name) throws IOException;

	/**
	 * 修改索引字段信息 <br/>
	 * 字段可以新增,已有的字段只能修改字段的 search_analyzer 属性。
	 * 
	 * @param name
	 *            - 索引名称
	 * @param propertyMap
	 *            - 索引字段,每个字段都有自己的property
	 * @throws IOException
	 */
	void updateIndexProperty(String name, HashMap<String, Property> propertyMap) throws IOException;

	/**
	 * 查询索引列表
	 * 
	 * @return
	 * @throws IOException
	 */
	GetIndexResponse getIndexList() throws IOException;

	/**
	 * 查询索引详情
	 *
	 * @param name
	 * @return
	 * @throws IOException
	 */
	GetIndexResponse getIndexDetail(String name) throws IOException;

	/**
	 * 检查指定名称的索引是否存在
	 * 
	 * @param name
	 * @return - true:存在
	 * @throws IOException
	 */
	boolean indexExists(String name) throws IOException;

}

实现类

@Service
@Slf4j
public class IndexServiceImpl implements IndexService {

    @Autowired
    private ElasticsearchClient elasticsearchClient;

    @Override
    public void createIndex(String name) throws IOException {
        //ApplicationContext applicationContext;
        CreateIndexResponse response = elasticsearchClient.indices().create(c -> c.index(name));
        log.info("createIndex方法,acknowledged={}", response.acknowledged());
    }

    @Override
    public void createIndex(String name,
                       Function<IndexSettings.Builder, ObjectBuilder<IndexSettings>> settingFn,
                       Function<TypeMapping.Builder, ObjectBuilder<TypeMapping>> mappingFn) throws IOException {
        CreateIndexResponse response = elasticsearchClient
                .indices()
                .create(c -> c
                        .index(name)
                        .settings(settingFn)
                        .mappings(mappingFn)
                );
        log.info("createIndex方法,acknowledged={}", response.acknowledged());
    }

    @Override
    public void deleteIndex(String name) throws IOException {
        DeleteIndexResponse response = elasticsearchClient.indices().delete(c -> c.index(name));
        log.info("deleteIndex方法,acknowledged={}", response.acknowledged());
    }

    @Override
    public void updateIndexProperty(String name, HashMap<String, Property> propertyMap) throws IOException {
        PutMappingResponse response = elasticsearchClient.indices()
                .putMapping(typeMappingBuilder ->
                                typeMappingBuilder
                                .index(name)
                                .properties(propertyMap)
        );
        log.info("updateIndexMapping方法,acknowledged={}", response.acknowledged());
    }

    @Override
    public GetIndexResponse getIndexList() throws IOException {
        //使用 * 或者 _all都可以
        GetIndexResponse response = elasticsearchClient.indices().get(builder -> builder.index("_all"));
        log.info("getIndexList方法,response.result()={}", response.result().toString());
        return response;
    }

    @Override
    public GetIndexResponse getIndexDetail(String name) throws IOException {
        GetIndexResponse response = elasticsearchClient.indices().get(builder -> builder.index(name));
        log.info("getIndexDetail方法,response.result()={}", response.result().toString());
        return response;
    }

    @Override
    public boolean indexExists(String name) throws IOException {
        return elasticsearchClient.indices().exists(b -> b.index(name)).value();
    }
  }

测试类

    @Autowired
    private IndexService indexService;

    @Test
    public void testCreateIndex() throws Exception {
        String indexName = "db_api_idx1";
        indexService.createIndex(indexName);

        //Assertions.assertTrue(indexService.indexExists(indexName));
        //indexService.createIndex(indexName);
        //Assertions.assertFalse(indexService.indexExists(indexName));
    }

    @Test
    public void testCreateIndex2() throws Exception {
        // 索引名
        String indexName = "db_api_idx2";

        // 构建setting
        Function<IndexSettings.Builder, ObjectBuilder<IndexSettings>> settingFn = sBuilder -> sBuilder
                .index(iBuilder -> iBuilder
                        // 三个分片
                        .numberOfShards("3")
                        // 一个副本
                        .numberOfReplicas("1")
                );



        // 索引字段,每个字段都有自己的property
        Property keywordProperty = Property.of(pBuilder -> pBuilder.keyword(keywordPropertyBuilder -> keywordPropertyBuilder.ignoreAbove(256)));
        Property integerProperty = Property.of(pBuilder -> pBuilder.integer(integerNumberPropertyBuilder -> integerNumberPropertyBuilder));
        Property textProperty = Property.of(pBuilder -> pBuilder.text(tBuilder -> tBuilder));

        // 构建mapping
        Function<TypeMapping.Builder, ObjectBuilder<TypeMapping>> mappingFn = mBuilder -> mBuilder
                .properties("name", keywordProperty)
                .properties("age", integerProperty)
                .properties("description", textProperty);

        // 创建索引,并指定setting和mapping
        indexService.createIndex(indexName, settingFn, mappingFn);
    }

    @Test
    public void testIndexExists() throws Exception {
        String indexName = "db_api_idx1";
        System.out.println(indexService.indexExists(indexName));
    }

    @Test
    public void testUpdateIndexProperty() throws Exception {
        String indexName = "db_api_idx2";

        // 索引字段,每个字段都有自己的property
        Property keywordProperty = Property.of(pBuilder -> pBuilder.keyword(keywordPropertyBuilder -> keywordPropertyBuilder.ignoreAbove(1024)));
        Property integerProperty = Property.of(pBuilder -> pBuilder.integer(integerNumberPropertyBuilder -> integerNumberPropertyBuilder));
        Property textProperty = Property.of(pBuilder -> pBuilder.text(tBuilder -> tBuilder));

        HashMap<String, Property> propertyMap = new HashMap<>();
        propertyMap.put("name", keywordProperty);
        propertyMap.put("description", textProperty);
        propertyMap.put("address", textProperty);

        // 构建mapping
        indexService.updateIndexProperty(indexName, propertyMap);
    }

    @Test
    public void testGetIndexList() throws Exception {
        indexService.getIndexList();
    }

    @Test
    public void testGetIndexDetail() throws Exception {
        String indexName = "db_api_idx2";
        indexService.getIndexDetail(indexName);
    }

    @Test
    public void testDeleteIndex() throws Exception {
        String indexName = "db_api_idx1";
        indexService.deleteIndex(indexName);
    }

文档操作

接口

public interface DocumentDemoService {

    /**
     * 新增一个文档
     * @param idxName 索引名
     * @param idxId 索引id
     * @param document 文档对象
     * @return
     */
    IndexResponse createByFluentDSL(String idxName, String idxId, Object document) throws Exception;

    /**
     * 新增一个文档
     * @param idxName 索引名
     * @param idxId 索引id
     * @param document 文档对象
     * @return
     */
    IndexResponse createByBuilderPattern(String idxName, String idxId, Object document) throws Exception;

    /**
     * 用JSON字符串创建文档
     * @param idxName 索引名
     * @param idxId 索引id
     * @param jsonContent
     * @return
     */
    IndexResponse createByJson(String idxName, String idxId, String jsonContent) throws Exception;


    /**
     * 异步新增文档
     * @param idxName 索引名
     * @param idxId 索引id
     * @param document
     * @param action
     */
    void createAsync(String idxName, String idxId, Object document, BiConsumer<IndexResponse, Throwable> action);

    /**
     * 批量增加文档
     * @param idxName 索引名
     * @param documents 要增加的对象集合
     * @return 批量操作的结果
     * @throws Exception
     */
    BulkResponse bulkCreate(String idxName, List<Object> documents) throws Exception;


    /**
     * 根据文档id查找文档
     * @param idxName 索引名
     * @param docId 文档id
     * @return Object类型的查找结果
     * @throws Exception
     */
    Object getById(String idxName, String docId) throws IOException;

    /**
     * 根据文档id查找文档,返回类型是ObjectNode
     * @param idxName 索引名
     * @param docId 文档id
     * @return ObjectNode类型的查找结果
     */
    ObjectNode getObjectNodeById(String idxName, String docId) throws IOException;

    /**
     * 根据文档id删除文档
     * @param idxName 索引名
     * @param docId 文档id
     * @return Object类型的查找结果
     * @throws Exception
     */
    Boolean deleteById(String idxName, String docId) throws IOException;

    /**
     * 批量删除文档
     * @param idxName 索引名
     * @param docIds 要删除的文档id集合
     * @return
     * @throws Exception
     */
    BulkResponse bulkDeleteByIds(String idxName, List<String> docIds) throws Exception;

}

实现类

@Slf4j
@Service
public class DocumentDemoServiceImpl implements DocumentDemoService {

    @Autowired
    private ElasticsearchClient elasticsearchClient;

    @Autowired
    private ElasticsearchAsyncClient elasticsearchAsyncClient;

    @Override
    public IndexResponse createByFluentDSL(String idxName, String idxId, Object document) throws Exception {
        IndexResponse response = elasticsearchClient.index(idx -> idx
                .index(idxName)
                .id(idxId)
                .document(document));
        return response;
    }

    @Override
    public IndexResponse createByBuilderPattern(String idxName, String idxId, Object document) throws Exception {
        IndexRequest.Builder<Object> indexReqBuilder = new IndexRequest.Builder<>();

        indexReqBuilder.index(idxName);
        indexReqBuilder.id(idxId);
        indexReqBuilder.document(document);
        return elasticsearchClient.index(indexReqBuilder.build());
    }

    @Override
    public IndexResponse createByJson(String idxName, String idxId, String jsonContent) throws Exception {
        return elasticsearchClient.index(i -> i
                .index(idxName)
                .id(idxId)
                .withJson(new StringReader(jsonContent))
        );
    }

    @Override
    public void createAsync(String idxName, String idxId, Object document, BiConsumer<IndexResponse, Throwable> action) {
        elasticsearchAsyncClient.index(idx -> idx
                .index(idxName)
                .id(idxId)
                .document(document)
        ).whenComplete(action);
    }

    @Override
    public BulkResponse bulkCreate(String idxName, List<Object> documents) throws Exception {
        BulkRequest.Builder br = new BulkRequest.Builder();

        // TODO 可以将 Object定义为一个文档基类。比如 ESDocument类

        // 将每一个product对象都放入builder中
        //documents.stream()
        //        .forEach(esDocument -> br
        //                .operations(op -> op
        //                        .index(idx -> idx
        //                                .index(idxName)
        //                                .id(esDocument.getId())
        //                                .document(esDocument))));

        return elasticsearchClient.bulk(br.build());
    }

    @Override
    public Object getById(String idxName, String docId) throws IOException {
        GetResponse<Object> response = elasticsearchClient.get(g -> g
                        .index(idxName)
                        .id(docId),
                Object.class);
        return response.found() ? response.source() : null;
    }

    @Override
    public ObjectNode getObjectNodeById(String idxName, String docId) throws IOException {
        GetResponse<ObjectNode> response = elasticsearchClient.get(g -> g
                        .index(idxName)
                        .id(docId),
                ObjectNode.class);

        return response.found() ? response.source() : null;
    }

    @Override
    public Boolean deleteById(String idxName, String docId) throws IOException {
        DeleteResponse delete = elasticsearchClient.delete(d -> d
                .index(idxName)
                .id(docId));
        return delete.forcedRefresh();
    }

    @Override
    public BulkResponse bulkDeleteByIds(String idxName, List<String> docIds) throws Exception {
        BulkRequest.Builder br = new BulkRequest.Builder();

        // 将每一个对象都放入builder中
        docIds.stream().forEach(id -> br
                        .operations(op -> op
                                .delete(d -> d
                                        .index(idxName)
                                        .id(id))));

        return elasticsearchClient.bulk(br.build());
    }
}

测试类

private final static String INDEX_NAME = "db_api_idx_uservo";

    @Autowired
    private DocumentDemoService documentDemoService;


    @Test
    public void testCreateByFluentDSL() throws Exception {
        // 构建文档数据
        UserVO userVO = new UserVO();
        userVO.setId(1L);
        userVO.setUserName("赵云2");
        userVO.setAge(11);
        userVO.setCreateTime(new Date());
        userVO.setUpdateTime(new Date());
        userVO.setEmail("ss.com");
        userVO.setVersion(1);
        userVO.setHeight(12D);

        // 新增一个文档
        IndexResponse response = documentDemoService.createByFluentDSL(INDEX_NAME, userVO.getId().toString(), userVO);

        System.out.println("response.forcedRefresh() -> " + response.forcedRefresh());
        System.out.println("response.toString() -> " + response.toString());
    }

    @Test
    public void testCreateByBuilderPattern() throws Exception {
        // 构建文档数据
        UserVO userVO = new UserVO();
        userVO.setId(2L);
        userVO.setUserName("赵云2");
        userVO.setAge(12);
        userVO.setCreateTime(new Date());
        userVO.setUpdateTime(new Date());
        userVO.setEmail("ss.com");
        userVO.setVersion(1);
        userVO.setHeight(12D);

        // 新增一个文档
        IndexResponse response = documentDemoService.createByBuilderPattern(INDEX_NAME, userVO.getId().toString(), userVO);

        System.out.println("response.toString() -> " + response.toString());
    }

    @Test
    public void testCreateByJSON() throws Exception {
        // 构建文档数据
        UserVO userVO = new UserVO();
        userVO.setId(3L);
        userVO.setUserName("赵云3");
        userVO.setAge(13);
        userVO.setCreateTime(new Date());
        userVO.setUpdateTime(new Date());
        userVO.setEmail("ss.com");
        userVO.setVersion(1);
        userVO.setHeight(12D);

        // 新增一个文档
        IndexResponse response = documentDemoService.createByJson(INDEX_NAME, userVO.getId().toString(), JSON.toJSONString(userVO));

        System.out.println("response.toString() -> " + response.toString());
    }

    @Test
    public void testCreateAsync() throws Exception {
        // 构建文档数据
        UserVO userVO = new UserVO();
        userVO.setId(4L);
        userVO.setUserName("赵云4");
        userVO.setAge(14);
        userVO.setCreateTime(new Date());
        userVO.setUpdateTime(new Date());
        userVO.setEmail("ss.com");
        userVO.setVersion(1);
        userVO.setHeight(12D);

        documentDemoService.createAsync(INDEX_NAME, userVO.getId().toString(), userVO, new BiConsumer<>() {
            @Override
            public void accept(IndexResponse indexResponse, Throwable throwable) {
                // throwable必须为空
                Assertions.assertNull(throwable);
                // 验证结果
                System.out.println("response.toString() -> " + indexResponse.toString());
            }
        });
    }

    @Test
    public void testBulkCreate() throws Exception {
        int start = 5;
        int end = 10;

        // 构造文档集合
        List<Object> list = new ArrayList<>();
        for (int i = 5; i <= 7; i++) {
            UserVO userVO = new UserVO();
            userVO.setId(Long.valueOf(i));
            userVO.setUserName("赵云batch" + i );
            userVO.setHeight(1.88D);
            userVO.setAge(10 + i);
            userVO.setCreateTime(new Date());
            list.add(userVO);
        }

        // 批量新增
        BulkResponse response = documentDemoService.bulkCreate(INDEX_NAME, list);
        List<BulkResponseItem> items = response.items();
        for (BulkResponseItem item : items) {
            System.out.println("BulkResponseItem.toString() -> " + item.toString());
        }
    }

    @Test
    public void testGetById() throws Exception {
        Long id = 1L;
        Object object = documentDemoService.getById(INDEX_NAME, id.toString());

        System.out.println("object ->" + object);
        // 无法直接强转,会报错
        //UserVO userVO = (UserVO) object;
        //System.out.println("userVO ->" + object);

    }

    @Test
    public void testGetObjectNode() throws Exception {
        Long id = 1L;
        ObjectNode objectNode = documentDemoService.getObjectNodeById(INDEX_NAME, id.toString());

        Assertions.assertNotNull(objectNode);
        System.out.println("id ->" + objectNode.get("id").asLong());
        System.out.println("userName ->" + objectNode.get("userName").asText());
    }

文章参考,出处 https://blog.csdn.net/qq_42402854/article/details/126686840

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

(十一)Springboot+ElasticSearch8整合 的相关文章

随机推荐

  • WY37 - 操作序列 - 网易

    java实现 题目描述 小易有一个长度为n的整数序列 a 1 a n 然后考虑在一个空序列b上进行n次以下操作 1 将a i放入b序列的末尾 2 逆置b序列 小易需要你计算输出操作n次之后的b序列 输入描述 输入包括两行 第一行包括一个整数
  • 如何将eclipse的英文设置成中文?

    点击eclipse选项栏中的 help 项 选择 install new solftware 可以看见如下界面 选择 添加 出现Add Repository界面 在名称处填写 babel 位置处粘贴如下库 https download ec
  • FPGA中的AXI总线

    网上有很多介绍AXI的文章 本篇或多或少参考了一些 其中的一些内容是我自己的理解 我认为比较适合新手 希望能帮助到才接触FPGA的萌新 一 AXI简介 AXI Advanced eXtensible Interface 直译过来就是先进的可
  • NEON优化:ARM优化高频指令总结

    NEON优化 ARM优化高频指令总结 前言 读写 计算 转换 操作 参考资料 NEON优化系列文章 NEON优化1 软件性能优化 降功耗怎么搞 link NEON优化2 ARM优化高频指令总结 link NEON优化3 矩阵转置的指令优化案
  • 保姆级vmware workstation Pro17安装紫色kali linux(KALI PURPLE)

    官方文档如下 官方文档 https gitlab com kalilinux kali purple documentation wikis home 虚拟机安装 下载vmware workstation Pro17 一路下一步安装完成 h
  • 使用python实现淘宝抢购

    疫情当下 大部分人选择网购 但是在有限数量的网购商品时 大家就需要蹲点抢了 而蹲点也不一定比别手快 有什么方法可以实现自动蹲点抢购呢 使用方法 1 先把想抢购的商品加入淘宝手机端的购物车 2 修改代码中抢购时间 3 运行代码 4 弹出浏览器
  • Flutter学习第三课-布局组件 Row和Column

    线性布局 所谓线性布局 即指沿水平或垂直方向排布子组件 Flutter中通过Row和Column来实现线性布局 Row 水平布局 Column 垂直布局 Row 和 Column 组件是不可以滚动的 所以在 Row 和Column 组件中不
  • 减少代码重复率的方法

    1 使用设计模式 设计模式的可以提高代码的复用率 减少代码的重复度 2 使用类模板或者函数模板 所谓的泛型编程
  • Python开发之DataFrame数据的多种遍历方法

    Python开发之DataFrame数据的多种遍历方法 1 遍历DataFrame的三种方法 2 按列遍历 3 按行遍历 3 1 第一种方法 3 2 第二种方法 4 遍历DataFrame某一列 行 数据 4 1 获取frame的index
  • Linux下输出彩色字符

    在 ANSI 兼容终端 例如 xterm rxvt konsole 等 里 可以用彩色显示文本而不仅仅是黑白 但是我们自己编写的程序能否输出彩色的字符呢 当然答案是肯定的 下面的语句就输出高亮的黑色背景的绿色字 printf 033 1 4
  • 【转载】keil消除*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS警告方法

    在Keil C中 如果没有显式调用到定义过的函数 就会出现这样的的警告 当出现这样的警告时 可以不用管 因为不影响其它部分 但是 我们知道 即使没有调用这个函数 Keil仍然把它编译连接进整个程序 不过浪费点ROM倒是不心疼 最主要的是 在
  • 京东高级Java现场面试37题:页锁+死锁+集群+雪崩+负载等

    京东现场三面面试题目 文末有福利 各大互联网公司经典面试题目及答案 京东一面 介绍一下自己 项目参与的核心设计有哪些 ArrayList和LinkedList底层 HashMap及线程安全的ConcurrentHashMap 以及各自优劣势
  • C语言--八大排序之希尔排序算法

    希尔 shell 排序 分组后 间隔式的分组 利用直接插入排序 简单来说就是 插入排序是间隔为一的数字之间进行比较 但希尔排序是间隔为gap的数字为一组 先进行一次插入排序 再不断缩小gap的值 重复以上操作 直到最后一个gap的值为1 分
  • C语言中求最大公约数的算法(三种)

    利用指针把三个数从大到小输出 最大公约数 指某几个整数共有约数中最大的一个 方法一 相减法 也叫更相减损法 思路 1 如果a gt b a a b 2 如果b gt a b b a 3 假如a b 则 a或 b是最大公约数 4 如果a b
  • 第一课:前言

    大家好 欢迎来到我的网站 人工智能被认为是一种拯救世界 终结世界的技术 毋庸置疑 人工智能时代就要来临了 科幻电影中的场景将成为现实 未来已来 我很庆幸 十四年前就认定了人工智能专业 一路学习着 从国内学到了国外 然后又回到了祖国参加工作
  • C++之private虚函数

    一般我们说虚函数 它的访问级别都是public的 用类对象可以直接调用 这样就可以实现运行时的类型绑定 那如果我们将虚函数私有化会出现什么情况呢 我们先来看一个非虚函数私有化的例子 class Base private void Print
  • LeetCode——051

    The n queens puzzle is the problem of placing n queens on an n n chessboard such that no two queens attack each other Gi
  • 支持目标打卡,活力三环让运动更有趣

    1 什么是活力三环 熟悉华为运动健康 华为智能穿戴的小伙伴们一定对 健康三环 有所了解 在最新版本的华为运动健康App以及HUAWEI WATCH 4 系列产品中 全新推出了 活力三环 助力用户养成运动习惯 保持活力满满 全新的 活力三环
  • 深入了解AS3 Socket 和TCP

    磨刀不误砍柴工 让我们从概念入手 逐步深入 所谓socket通常也称作 套接字 用于描述IP地址和端口 是一个通信链的句柄 应用程序通常通过 套接字 向网络发出请求或者应答网络请求 Socket 通讯是我们开发多人在线游戏中的常用通讯方式
  • (十一)Springboot+ElasticSearch8整合

    前言 在 Elasticsearch7 15版本之后 Elasticsearch官方将它的高级客户端 RestHighLevelClient标记为弃用状态 推出全新的 Java API客户端 Elasticsearch Java API C