java实现置顶排序功能

使用的是当前时间作为排序

默认是拿到上一个排序号减一作为当前排序的排序号,但是有可能会重复排序号

所以当前排序号后面的数据要顺延-1处理

 @Override
    public void topSort(String targetContentId) {
        if (targetContentId.equals(this.getContentEntity().getId())) {
            return; // 排序目标是自己直接返回
        }
        checkLock();
        //上一条数据
        CmsArticle prev = this.getArticleService().getById(targetContentId);
        Long topFlag = prev.getTopFlag() - 1;
        this.content.setTopFlag(topFlag);
        //排序时间重复 则后面的数据顺延-1
        LambdaQueryWrapper q = new LambdaQueryWrapper<CmsArticle>()
                .eq(CmsArticle::getCategoryId, prev.getCategoryId())
                .ne(CmsArticle::getTopFlag, '0')
                .ne(CmsArticle::getTopFlagType, 'N')
                .le(CmsArticle::getTopFlag, topFlag)
                .orderByDesc(CmsArticle::getTopFlag).orderByDesc(CmsArticle::getSortFlag);
        List<CmsArticle> articles = this.getArticleService().getContentMapper().selectList(q);
        recursiveSort(articles, 0, topFlag);
        // 批量更新文章信息
        this.getArticleService().saveOrUpdateBatch(articles);
        this.getArticleService().updateById(content);
    }

    public void recursiveSort(List<CmsArticle> articles, int start, Long topFlag) {
        if (start >= articles.size()) {
            return;  // 递归结束条件:已经遍历完整个列表
        }
        CmsArticle currArticle = articles.get(start);
        if (currArticle.getTopFlag().equals(topFlag)) {
            currArticle.setTopFlag(topFlag - 1);  // 顺延-1处理
            topFlag--;
        }
        recursiveSort(articles, start + 1, topFlag);  // 递归遍历下一篇文章
    }

spring获取 map bean

package com.jinw.utils.cms;

import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import java.util.Map;

/**
 * spring工具类 方便在非spring管理环境中获取bean
 *
 * @author ruoyi
 */
@Component
public final class CmsSpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware {

    /**
     * Spring应用上下文环境
     */
    private static ConfigurableListableBeanFactory beanFactory;

    private static ApplicationContext applicationContext;

    /**
     * 获取对象
     *
     * @param name
     * @return Object 一个以所给名字注册的bean的实例
     * @throws org.springframework.beans.BeansException
     */
    @SuppressWarnings("unchecked")
    public static <T> T getBean(String name) throws BeansException {
        return (T) beanFactory.getBean(name);
    }

    /**
     * 获取类型为requiredType的对象
     *
     * @param clz
     * @return
     * @throws org.springframework.beans.BeansException
     */
    public static <T> T getBean(Class<T> clz) throws BeansException {
        T result = (T) beanFactory.getBean(clz);
        return result;
    }

    public static <T> Map<String, T> getBeanMap(Class<T> claz) {
        return beanFactory.getBeansOfType(claz);
    }

    /**
     * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
     *
     * @param name
     * @return boolean
     */
    public static boolean containsBean(String name) {
        return beanFactory.containsBean(name);
    }

    /**
     * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。
     * 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
     *
     * @param name
     * @return boolean
     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
     */
    public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
        return beanFactory.isSingleton(name);
    }

    /**
     * @param name
     * @return Class 注册对象的类型
     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
     */
    public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
        return beanFactory.getType(name);
    }

    /**
     * 如果给定的bean名字在bean定义中有别名,则返回这些别名
     *
     * @param name
     * @return
     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
     */
    public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
        return beanFactory.getAliases(name);
    }

    /**
     * 获取aop代理对象
     *
     * @param invoker
     * @return
     */
    @SuppressWarnings("unchecked")
    public static <T> T getAopProxy(T invoker) {
        return (T) AopContext.currentProxy();
    }

    /**
     * 获取当前的环境配置,无配置返回null
     *
     * @return 当前的环境配置
     */
    public static String[] getActiveProfiles() {
        return applicationContext.getEnvironment().getActiveProfiles();
    }

    /**
     * 获取当前的环境配置,当有多个环境配置时,只获取第一个
     *
     * @return 当前的环境配置
     */
    public static String getActiveProfile() {
        final String[] activeProfiles = getActiveProfiles();
        return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
    }

    /**
     * 获取配置文件中的值
     *
     * @param key 配置文件的key
     * @return 当前的配置文件的值
     */
    public static String getRequiredProperty(String key) {
        return applicationContext.getEnvironment().getRequiredProperty(key);
    }

    /**
     * 获取应用当前所在目录
     *
     * @return
     * @throws FileNotFoundException
     * @throws URISyntaxException
     */
    public static String getAppParentDirectory() {
        ApplicationHome applicationHome = new ApplicationHome(CmsSpringUtils.class);
        File applicationDir = applicationHome.getSource();
        String[] activeProfiles = applicationContext.getEnvironment().getActiveProfiles();
        if (ArrayUtils.indexOf("dev", activeProfiles) > -1) {
            String dirPath = FileExUtils.normalizePath(applicationHome.getSource().getAbsolutePath());
            applicationDir = new File(StringUtils.substringBefore(dirPath, "/kingow-oa/"));
        }
        String dir = FileExUtils.normalizePath(applicationDir.getParentFile().getAbsolutePath());
        if (dir.indexOf("/BOOT-INF/lib") > -1) {
            dir = StringUtils.substringBefore(dir, "/BOOT-INF/lib");
        }
        return dir;
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        CmsSpringUtils.beanFactory = beanFactory;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        CmsSpringUtils.applicationContext = applicationContext;
    }
}

Flyway和Liquibase

安装

下载、解压Liquibase: https://download.liquibase.org
安装java(配置环境变量)
下载数据库驱动包放到Liquibase目录下的lib

springboot 配置elasticsearch

package com.jinw.cms.config;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.message.BasicHeader;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StringUtils;

import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.Arrays;

@ConfigurationProperties(prefix = "spring.elasticsearch") //配置的前缀
@Configuration
@Slf4j
public class ElasticsearchConfig {
    @Setter
    private String uris;
    @Setter
    private String username;
    @Setter
    private String password;

    /**
     * 解析配置的字符串,转为HttpHost对象数组
     *
     * @return
     */
    private HttpHost[] toHttpHost() {
        if (!StringUtils.hasLength(uris)) {
            throw new RuntimeException("invalid elasticsearch configuration");
        }
        String[] hostArray = uris.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;
    }

    @Bean("clientByPasswd")
    public ElasticsearchClient clientByPasswd() throws Exception {
        ElasticsearchTransport transport = getElasticsearchTransport(username, password, toHttpHost());
        return new ElasticsearchClient(transport);
    }

    private static SSLContext buildSSLContext() {
        ClassPathResource resource = new ClassPathResource("es01.crt");
        SSLContext sslContext = null;
        try {
            CertificateFactory factory = CertificateFactory.getInstance("X.509");
            Certificate trustedCa;
            try (InputStream is = resource.getInputStream()) {
                trustedCa = factory.generateCertificate(is);
            }
            KeyStore trustStore = KeyStore.getInstance("pkcs12");
            trustStore.load(null, null);
            trustStore.setCertificateEntry("ca", trustedCa);
            SSLContextBuilder sslContextBuilder = SSLContexts.custom()
                    .loadTrustMaterial(trustStore, null);
            sslContext = sslContextBuilder.build();
        } catch (CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException |
                KeyManagementException e) {
            log.error("ES连接认证失败", e);
        }
        return sslContext;
    }

    private static ElasticsearchTransport getElasticsearchTransport(String username, String passwd, HttpHost... hosts) {
        // 账号密码的配置
        final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
        credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, passwd));
        // 自签证书的设置,并且还包含了账号密码
        HttpClientConfigCallback callback = httpAsyncClientBuilder -> httpAsyncClientBuilder
//                .setSSLContext(buildSSLContext())    //  证书式认证方式
                .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                .setDefaultCredentialsProvider(credentialsProvider)
                //  Todo 这里是关键  ######################解决 X-Elastic-Product  问题开始
                .setDefaultHeaders(
                        Arrays.asList(
                                new BasicHeader(
                                        HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString())))
                .addInterceptorLast(
                        (HttpResponseInterceptor)
                                (response, context) ->
                                        response.addHeader("X-Elastic-Product", "Elasticsearch"));
        // X-Elastic-Product   end
        // 用builder创建RestClient对象
        RestClient client = RestClient
                .builder(hosts)
                .setHttpClientConfigCallback(callback)
                .build();
        return new RestClientTransport(client, new JacksonJsonpMapper());
    }

    private static ElasticsearchTransport getElasticsearchTransport(String apiKey, HttpHost... hosts) {
        // 将ApiKey放入header中
        Header[] headers = new Header[]{new BasicHeader("Authorization", "ApiKey " + apiKey)};
        // es自签证书的设置
        HttpClientConfigCallback callback = httpAsyncClientBuilder -> httpAsyncClientBuilder
                .setSSLContext(buildSSLContext())
                .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
        // 用builder创建RestClient对象
        RestClient client = RestClient
                .builder(hosts)
                .setHttpClientConfigCallback(callback)
                .setDefaultHeaders(headers)
                .build();
        return new RestClientTransport(client, new JacksonJsonpMapper());
    }
}
spring:
  elasticsearch:
    uris: 127.0.0.1:9200
    username: elastic
    password: 123456
    connection-timeout: 10000
    socket-timeout: 30s
package com.jinw.cms.service.impl;


import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import co.elastic.clients.elasticsearch._types.mapping.Property;
import co.elastic.clients.elasticsearch.core.GetResponse;
import co.elastic.clients.elasticsearch.core.bulk.BulkOperation;
import co.elastic.clients.elasticsearch.indices.CreateIndexResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinw.cms.constants.*;
import com.jinw.cms.content.IContent;
import com.jinw.cms.content.type.IContentType;
import com.jinw.cms.entity.CmsArticle;
import com.jinw.cms.entity.CmsCategory;
import com.jinw.cms.entity.CmsSite;
import com.jinw.cms.entity.ESContent;
import com.jinw.cms.mapper.CmsCategoryMapper;
import com.jinw.cms.service.ICmsArticleService;
import com.jinw.cms.service.ICmsSiteService;
import com.jinw.utils.cms.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@RequiredArgsConstructor
@Service
public class ContentIndexService implements CommandLineRunner {

    private final ICmsSiteService siteService;

    private final CmsCategoryMapper cmsCategoryMapper;
    private final ICmsArticleService contentService;


    private final ElasticsearchClient esClient;


    private void createIndex() throws IOException {
        // 创建索引
        Map<String, Property> properties = new HashMap<>();
        properties.put("catalogAncestors", Property.of(fn -> fn.keyword(b -> b
                .ignoreAbove(500) // 指定字符串字段的最大长度。超过该长度的字符串将被截断或忽略。
        )));
        properties.put("contentType", Property.of(fn -> fn.keyword(b -> b
                .ignoreAbove(20)
        )));
        properties.put("logo", Property.of(fn -> fn.keyword(b -> b
                .ignoreAbove(256)
        )));
        properties.put("title", Property.of(fn -> fn.text(b -> b
                .store(true) // 是否存储在索引中
                .analyzer(SearchConsts.IKAnalyzeType_Smart)
        )));
        properties.put("fullText", Property.of(fn -> fn.text(b -> b
                .analyzer(SearchConsts.IKAnalyzeType_Smart)
        )));
        CreateIndexResponse response = esClient.indices().create(fn -> fn
                .index(ESContent.INDEX_NAME)
                .mappings(mb -> mb.properties(properties)));
        Assert.isTrue(response.acknowledged(), () -> new RuntimeException("Create Index[cms_article] failed."));
    }

    public void recreateIndex(CmsSite site) throws IOException {
        boolean exists = esClient.indices().exists(fn -> fn.index(ESContent.INDEX_NAME)).value();
        if (!exists) {
            this.createIndex();
        } else {
            // 删除站点索引文档数据
            long total = this.contentService.getContentMapper().selectCount(Wrappers.lambdaQuery(CmsArticle.class).eq(CmsArticle::getSiteId, site.getId()));
            long pageSize = 1000;
            for (int i = 0; i * pageSize < total; i++) {
                List<String> contentIds = this.contentService.getContentMapper().selectPage(
                        new Page<>(i, pageSize, false), Wrappers.lambdaQuery(CmsArticle.class).eq(CmsArticle::getSiteId, site.getId())
                ).getRecords().stream().map(CmsArticle::getId).collect(Collectors.toList());
                deleteContentDoc(contentIds);
            }
        }
    }

    /**
     * 创建/更新内容索引Document
     */
    public void createContentDoc(IContent<?> content) {
        // 判断栏目/站点配置是否生成索引
        String enableIndex = EnableIndexProperty.getValue(content.getCatalog().getConfigProps(),
                content.getSite().getConfigProps());
        if (YesOrNo.isNo(enableIndex)) {
            return;
        }
        try {
            esClient.update(fn -> fn
                    .index(ESContent.INDEX_NAME)
                    .id(content.getContentEntity().getId().toString())
                    .doc(newESContentDoc(content))
                    .docAsUpsert(true), ESContent.class);
        } catch (ElasticsearchException | IOException e) {
            //   AsyncTaskManager.addErrMessage(e.getMessage());
            e.printStackTrace();
        }
    }

    private void batchContentDoc(CmsSite site, CmsCategory catalog, List<CmsArticle> contents) {
        if (contents.isEmpty()) {
            return;
        }
        List<BulkOperation> bulkOperationList = new ArrayList<>(contents.size());
        for (CmsArticle xContent : contents) {
            // 判断栏目/站点配置是否生成索引
            String enableIndex = EnableIndexProperty.getValue(catalog.getConfigProps(), site.getConfigProps());
            if (YesOrNo.isYes(enableIndex)) {
                IContentType contentType = ContentCoreUtils.getContentType(xContent.getContentType());
                IContent<?> icontent = contentType.loadContent(xContent);
                BulkOperation bulkOperation = BulkOperation.of(b ->
                                b.update(up -> up.index(ESContent.INDEX_NAME)
                                        .id(xContent.getId().toString())
                                        .action(action -> action.docAsUpsert(true).doc(newESContentDoc(icontent))))
//                        b.create(co -> co.index(ESContent.INDEX_NAME)
//                        .id(xContent.getContentId().toString()).document(newESContent(icontent)))
                );
                bulkOperationList.add(bulkOperation);
            }
        }
        if (bulkOperationList.isEmpty()) {
            return;
        }
        // 批量新增索引
        try {
            esClient.bulk(bulk -> bulk.operations(bulkOperationList));
        } catch (ElasticsearchException | IOException e) {
            //  AsyncTaskManager.addErrMessage(e.getMessage());
            e.printStackTrace();
        }
    }

    /**
     * 删除内容索引
     */
    public void deleteContentDoc(List<String> contentIds) throws ElasticsearchException, IOException {
        List<BulkOperation> bulkOperationList = contentIds.stream().map(contentId -> BulkOperation
                .of(b -> b.delete(dq -> dq.index(ESContent.INDEX_NAME).id(contentId.toString())))).collect(Collectors.toList());
        this.esClient.bulk(bulk -> bulk.operations(bulkOperationList));
    }

    public void rebuildCatalog(CmsCategory catalog, boolean includeChild) {
        CmsSite site = this.siteService.getSite(catalog.getSiteId());
        String enableIndex = EnableIndexProperty.getValue(catalog.getConfigProps(), site.getConfigProps());
        if (YesOrNo.isYes(enableIndex)) {
            LambdaQueryWrapper<CmsArticle> q = new LambdaQueryWrapper<CmsArticle>()
                    .ne(CmsArticle::getCopyType, ContentCopyType.Mapping)
                    .eq(CmsArticle::getStatus, ContentStatus.PUBLISHED)
                    .eq(!includeChild, CmsArticle::getCategoryId, catalog.getId())
                    .likeRight(includeChild, CmsArticle::getCategoryAncestors, catalog.getAncestors());
            long total = this.contentService.getContentMapper().selectCount(q);
            long pageSize = 200;
            for (int i = 0; i * pageSize < total; i++) {
                Page<CmsArticle> page = contentService.getContentMapper().selectPage(new Page<>(i, pageSize, false), q);
                batchContentDoc(site, catalog, page.getRecords());
            }
        }
    }

    /**
     * 重建指定站点所有内容索引
     */
    public void rebuildAll(CmsSite site) throws IOException {
        // 先重建索引
        recreateIndex(site);

        List<CmsCategory> catalogs = cmsCategoryMapper.selectList(Wrappers.lambdaQuery());
        for (CmsCategory category : catalogs) {
            LambdaQueryWrapper<CmsArticle> q = new LambdaQueryWrapper<CmsArticle>()
                    .eq(CmsArticle::getSiteId, site.getId())
                    .ne(CmsArticle::getCopyType, ContentCopyType.Mapping)
                    .eq(CmsArticle::getStatus, ContentStatus.PUBLISHED)
                    .eq(CmsArticle::getCategoryId, category.getId());
            long total = contentService.getContentMapper().selectCount(q);
            int pageSize = 200;
            int count = 1;
            for (int i = 0; (long) i * pageSize < total; i++) {
                log.debug((int) (count++ * 100 / total) + "正在重建栏目【" + category.getName() + "】内容索引");
                Page<CmsArticle> page = contentService.getContentMapper().selectPage(new Page<>(i, pageSize, false), q);
                batchContentDoc(site, category, page.getRecords());
                // AsyncTaskManager.checkInterrupt(); // 允许中断
            }
        }
        log.debug("100% 重建全站索引完成");
    }


    /**
     * 获取指定内容索引详情
     *
     * @param contentId 内容ID
     * @return 索引Document详情
     */
    public ESContent getContentDocDetail(String contentId) throws ElasticsearchException, IOException {
        GetResponse<ESContent> res = this.esClient.get(qb -> qb.index(ESContent.INDEX_NAME).id(contentId.toString()),
                ESContent.class);
        return res.source();
    }

    private Map<String, Object> newESContentDoc(IContent<?> content) {
        Map<String, Object> data = new HashMap<>();
        data.put("contentId", content.getContentEntity().getId());
        data.put("contentType", content.getContentEntity().getContentType());
        data.put("siteId", content.getSiteId());
        data.put("catalogId", content.getCatalogId());
        data.put("catalogAncestors", content.getContentEntity().getCategoryAncestors());
        data.put("author", content.getContentEntity().getAuthor());
        data.put("editor", content.getContentEntity().getEditor());
        data.put("keywords", StringUtils.join(content.getContentEntity().getKeywords()));
        data.put("tags", StringUtils.join(content.getContentEntity().getTags()));
        data.put("createTime", content.getContentEntity().getCreateTime());
        data.put("logo", content.getContentEntity().getLogo());
        data.put("status", content.getContentEntity().getStatus());
        data.put("publishDate", content.getContentEntity().getPublishDate().toEpochSecond(ZoneOffset.UTC));
        data.put("link", InternalUrlUtils.getInternalUrl(InternalDataType_Content.ID, content.getContentEntity().getId()));
        data.put("title", content.getContentEntity().getTitle());
        data.put("summary", content.getContentEntity().getSummary());
        data.put("fullText", content.getFullText());
        // 扩展模型数据
//        this.extendModelService.getModelData(content.getContentEntity()).forEach(fd -> {
//            data.put(fd.getFieldName(), fd.getValue());
//        });
        return data;
    }

    public boolean isElasticSearchAvailable() {
        try {
            return esClient.ping().value();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public void run(String... args) throws Exception {
        if (isElasticSearchAvailable()) {
            boolean exists = esClient.indices().exists(fn -> fn.index(ESContent.INDEX_NAME)).value();
            if (!exists) {
                this.createIndex(); // 创建内容索引库
            }
        } else {
            log.warn("ES service not available!");
        }
    }
}
 <elasticsearch-java>8.6.2</elasticsearch-java>
 <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>${elasticsearch-java}</version>
            <!--排除这些组件-->
            <exclusions>
                <exclusion>
                    <artifactId>jakarta.json-api</artifactId>
                    <groupId>jakarta.json</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>elasticsearch-rest-client</artifactId>
                    <groupId>org.elasticsearch.client</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>${elasticsearch-java}</version>
        </dependency>