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
    • 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);}}

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);}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/335322.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

使用python绘制一个五颜六色的爱心

使用python绘制一个五颜六色的爱心 介绍效果代码 介绍 使用numpy与matplotlib绘制一个七彩爱心&#xff01; 效果 代码 import numpy as np import matplotlib.pyplot as plt# Heart shape function def heart_shape(t):x 16 * np.sin(t)**3y 13 * np.cos(t) - 5 * np.cos…

【RabbitMQ】SpringAMQP--消息转换器

SpringAMQP–消息转换器 测试发送Object类型消息 1.声明队列 Configuration public class FanoutConfig {Beanpublic Queue objectQueue(){return new Queue("object.queue");} }运行消费者后&#xff1a; 2.发送消息 RunWith(SpringRunner.class) SpringBootTes…

POLARDB:新零售用户MySQL上云最佳选择

什么是云数据库POLARDB&#xff1f; POLARDB是阿里云自主研发的最新一代RDS关系型数据库&#xff0c;是特别针对互联网场景设计的Cloud-Native 云原生数据库。POLARDB for MySQL版本&#xff0c;在提供100%兼容MySQL5.6/8.0的关系型事务处理ACID特性之上&#xff0c;能够提供完…

如何让社区版IDEA变得好用

如何让社区版IDEA变得好用 背景 收费版的idea功能非常强大&#xff0c;但是收费&#xff1b;社区版的免费&#xff0c;但是功能被阉割了。如何才能让社区版Idea变得好用&#xff0c;一、打开项目前进行全局配置&#xff1b;二&#xff0c;寻求各种插件的支持。在经过全局配置…

迅睿CMS邮箱设置QQ邮箱为例

邮箱设置 1、服务器地址两个&#xff0c;普通与企业。 普通&#xff1a;ssl://smtp.qq.com企业&#xff1a;ssl://smtp.exmail.qq.com 2、端口号为&#xff1a;465 3、邮箱账号&#xff1a;填写自己的QQ邮箱作为发布服务器。 4、邮箱密码&#xff1a;到QQ邮箱账号中获取“…

Git学习篇

目录 使用命令导入项目 使用命令导入项目 1. 使用git init 命令初始化一个新的Git仓库。 git init 是 Git 命令&#xff0c;用于初始化一个新的 Git 仓库。当您想要开始跟踪一个新项目的版本控制时&#xff0c;可以运行 git init 命令来初始化一个空的 Git 仓库。 如果出现以下…

Windows电脑高颜值桌面便利贴,便签怎么设置

在这个看颜值的时代&#xff0c;我们不仅在衣着打扮上追求时尚与美观&#xff0c;就连电脑桌面也不愿放过。一张唯美的壁纸&#xff0c;几款别致的小工具&#xff0c;总能让我们的工作空间焕发出不一样的光彩。如果你也热衷于打造高颜值的电脑桌面&#xff0c;那么&#xff0c;…

用docker搭建的Vulfocus镜像管理界面没有镜像可以拉取解决办法

ps&#xff1a;截止到今天2023.4.2&#xff0c;kali和vps的docker拉取的vulfocus镜像会有版本的区别&#xff0c;虽然都是拉取的最新版&#xff0c;vps上镜像为3个月以前&#xff0c;kali上为16个月以前&#xff0c;所以在修改 views.py 文件时&#xff0c;可能会发现文件内容不…

国产化服务器开启NTP功能并向NTP时钟服务器同步

1.备份/etc/chrony.conf文件&#xff1b; cp -rp /etc/chrony.conf /etc/chrony.conf.bak.20240522 2.修改chrony.conf文件&#xff0c;增加NTP时钟信息。&#xff08;客户端填写时钟同步服务器的IP地址或者域名&#xff0c;我这里写的IP地址。下面Allow NTP Client是只允许…

易备数据备份软件: 快速备份 MySQL\SQL Server\Oracle\泛微 OA 数据库

易备数据备份软件支持对 SQL Server、Oracle、MySQL、PostgreSQL、MariaDB、泛微 OA 等数据库进行快速备份&#xff0c;备份过程不会对任何服务造成中断。 使用一份授权&#xff0c;可以备份无限量的数据库&#xff0c;不管数据库服务器是否在本机、本地网络、或是远程网络。可…

文心智能体平台 | 想象即现实

目录 文心智能体平台介绍平台简介通过平台能做什么平台的优势智能体介绍智能体类型AI 插件介绍 动手创建一个智能体访问平台并进行账号注册根据适合的方式选择智能体类型快速创建智能体智能体个性化模块配置 总结注意事项我的智能体 文心智能体平台介绍 平台简介 文心智能体平…

1、C++编程概述

文章目录 一、基本概念二、数据的表示及运算计算机中数据表示进制间相互转化二进制计算规则 三、计算机数据的存储单位四、机器数和码制五、机器数运算机器数的加减运算机器数的乘除运算 面向对象编程语言把事物看成是具有属性和行为的对象&#xff0c;然后通过抽象找出属于同一…

共筑信创新生态:DolphinDB 与移动云 BC-Linux 完成兼容互认

近日&#xff0c;DolphinDB 数据库软件 V2.0 与中国移动通信集团公司的移动云天元操作系统 BC-Linux 完成兼容性适配认证。经过双方共同严格测试&#xff0c;DolphinDB 性能及稳定性等各项指标表现优异&#xff0c;满足功能及兼容性测试要求。 此次 DolphinDB 成功通过移动云 B…

AWS 高防和阿里云高防深度对比

随着网络攻击的不断增加&#xff0c;企业对于网络安全的需求也越来越高。在这种情况下&#xff0c;高防护服务成为了企业网络安全的重要组成部分。AWS和阿里云作为全球领先的云计算服务提供商&#xff0c;都提供了高防护服务&#xff0c;但它们之间存在着一些差异。我们九河云一…

如何让Google快速收录?

要让Google快速收录你的网站&#xff0c;可以考虑使用GSI服务&#xff0c;这是一种专门设计来加速网站被Google搜索引擎收录的服务&#xff0c;下面详细解释GSI服务的基本原理和具体好处&#xff1a; GSI服务通过一种名为GPC爬虫池的系统实现&#xff0c;这个系统是基于对Goog…

ABAP Json解析案例

ABAP解析返回的JSON 案例 DATA:LTOKEN TYPE STRING.DATA: LL_LINES(10),"行数LL_TABIX(10),"循环标号LL_PECNT TYPE P LENGTH 6 DECIMALS 2, "百分比LL_PECET(6),"百分数LL_TEXT(40)."消息CLEAR: LL_LINES,LL_TABIX,LL_PECNT,LL_PECET,LL_TEXT.* …

GPT-4o: 未来的智能助手

GPT-4o: 未来的智能助手 在这个信息爆炸的时代&#xff0c;人工智能&#xff08;AI&#xff09;已经成为我们生活中不可或缺的一部分。作为OpenAI最新推出的语言模型&#xff0c;GPT-4o不仅继承了前几代模型的优点&#xff0c;还在多个方面进行了显著的提升。本文将带你深入了解…

Win11有些exe双击后无反应的解决办法

现象 双击某些exe文件之后&#xff0c;小圆圈转了两下之后就消失&#xff0c;然后没任何反应。用回车反复启动也是一样的现象。 由于截图没法截图到鼠标&#xff0c;所以没法放出截图。 我电脑出现上述现象的软件有&#xff1a; 1.纸飞机调试助手 2.SOC Programming Tool 对…

【python】numpy库计算矩阵特征值和特征向量

目录 0.环境 1.前提 2.全部代码 0.环境 windows eclipse python 1.前提 我的邻接矩阵是固定的&#xff0c;11*11 2.全部代码 要将邻接矩阵使用numpy赋值 #计算矩阵特征值 import numpy as np A np.array([[0,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0…

虹科Pico汽车示波器 | 免拆诊断案例 | 2010 款北京现代ix35车挡位偶尔锁定在4挡

故障现象 一辆2010款北京现代ix35车&#xff0c;搭载G4KD发动机和6速自动变速器&#xff0c;累计行驶里程约为23.6万km。该车行驶中急加速时&#xff0c;挡位偶尔锁定在4挡&#xff0c;同时发动机故障灯异常点亮。 故障诊断 该车自动变速器控制模块&#xff08;TCM&#xff0…