From a3a2384c95a94b2cd3a9d4ca97b97d776fea179e Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Wed, 21 Sep 2022 16:57:14 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E5=8D=87=E7=BA=A7=20Spring=20Boot=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 35 +++++++++++++------ .../xxyopen/novel/core/config/EsConfig.java | 21 +++-------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 6a006f9..9d25a1b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,8 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.0.0-M3</version> + <version>3.0.0-M4</version> + <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>io.github.xxyopen</groupId> <artifactId>novel</artifactId> @@ -16,6 +17,7 @@ <properties> <java.version>17</java.version> <mybatis-plus.version>3.5.1</mybatis-plus.version> + <spring.version>6.0.0-SNAPSHOT</spring.version> <jjwt.version>0.11.5</jjwt.version> <elasticsearch.version>8.2.0</elasticsearch.version> <xxl-job.version>2.3.1</xxl-job.version> @@ -233,15 +235,20 @@ </snapshots> </repository> <repository> - <id>spring-snapshots</id> - <url>https://repo.spring.io/snapshot</url> + <id>spring-milestones</id> + <name>Spring Milestones</name> + <url>https://repo.spring.io/milestone</url> <snapshots> - <enabled>true</enabled> + <enabled>false</enabled> </snapshots> </repository> <repository> - <id>spring-milestones</id> - <url>https://repo.spring.io/milestone</url> + <id>spring-snapshots</id> + <name>Spring Snapshots</name> + <url>https://repo.spring.io/snapshot</url> + <releases> + <enabled>false</enabled> + </releases> </repository> <repository> <id>sonatype-nexus-snapshots</id> @@ -278,12 +285,20 @@ </snapshots> </pluginRepository> <pluginRepository> - <id>spring-snapshots</id> - <url>https://repo.spring.io/snapshot</url> + <id>spring-milestones</id> + <name>Spring Milestones</name> + <url>https://repo.spring.io/milestone</url> + <snapshots> + <enabled>false</enabled> + </snapshots> </pluginRepository> <pluginRepository> - <id>spring-milestones</id> - <url>https://repo.spring.io/milestone</url> + <id>spring-snapshots</id> + <name>Spring Snapshots</name> + <url>https://repo.spring.io/snapshot</url> + <releases> + <enabled>false</enabled> + </releases> </pluginRepository> </pluginRepositories> diff --git a/src/main/java/io/github/xxyopen/novel/core/config/EsConfig.java b/src/main/java/io/github/xxyopen/novel/core/config/EsConfig.java index 0bb2fb9..58eafa9 100644 --- a/src/main/java/io/github/xxyopen/novel/core/config/EsConfig.java +++ b/src/main/java/io/github/xxyopen/novel/core/config/EsConfig.java @@ -1,12 +1,6 @@ package io.github.xxyopen.novel.core.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.RequiredArgsConstructor; -import org.elasticsearch.client.RestClient; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,19 +11,14 @@ import org.springframework.context.annotation.Configuration; * @date 2022/5/23 */ @Configuration -@ConditionalOnProperty(prefix = "spring.elasticsearch", name = "enabled", havingValue = "true") -@RequiredArgsConstructor public class EsConfig { + /** + * 解决 ElasticsearchClientConfigurations 修改默认 ObjectMapper 配置的问题 + */ @Bean - public ElasticsearchClient elasticsearchClient(RestClient restClient) { - - // Create the transport with a Jackson mapper - ElasticsearchTransport transport = new RestClientTransport( - restClient, new JacksonJsonpMapper()); - - // And create the API client - return new ElasticsearchClient(transport); + JacksonJsonpMapper jacksonJsonpMapper() { + return new JacksonJsonpMapper(); } }