update easy-es 2.1.0 => 3.0.0

This commit is contained in:
疯狂的狮子Li
2025-06-05 15:12:50 +08:00
parent 1321a1ec38
commit 6d319b13ad
4 changed files with 3 additions and 112 deletions

View File

@@ -36,7 +36,7 @@
<satoken.version>1.42.0</satoken.version>
<lombok.version>1.18.36</lombok.version>
<logstash.version>7.4</logstash.version>
<easy-es.version>2.1.0</easy-es.version>
<easy-es.version>3.0.0</easy-es.version>
<skywalking-toolkit.version>9.3.0</skywalking-toolkit.version>
<bouncycastle.version>1.80</bouncycastle.version>
<mapstruct-plus.version>1.4.8</mapstruct-plus.version>

View File

@@ -1,84 +0,0 @@
package org.dromara.easyes.spring.config;
import lombok.Setter;
import org.dromara.easyes.common.property.EasyEsDynamicProperties;
import org.dromara.easyes.common.property.EasyEsProperties;
import org.dromara.easyes.common.strategy.AutoProcessIndexStrategy;
import org.dromara.easyes.common.utils.RestHighLevelClientUtils;
import org.dromara.easyes.core.index.AutoProcessIndexNotSmoothlyStrategy;
import org.dromara.easyes.core.index.AutoProcessIndexSmoothlyStrategy;
import org.dromara.easyes.spring.factory.IndexStrategyFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
import java.util.Map;
/**
* @author MoJie
* @since 2.0
*/
@Setter
@Configuration
@ConditionalOnProperty(value = "easy-es.enable", havingValue = "true")
public class EasyEsConfiguration implements InitializingBean {
private EasyEsProperties easyEsProperties;
private EasyEsDynamicProperties easyEsDynamicProperties;
@Autowired
public EasyEsConfiguration(EasyEsProperties easyEsProperties, EasyEsDynamicProperties easyEsDynamicProperties) {
this.easyEsProperties = easyEsProperties;
this.easyEsDynamicProperties = easyEsDynamicProperties;
}
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(this.easyEsProperties, "easyEsProperties must is A bean. easy-es配置类必须给配置一个bean");
}
@Bean
public IndexStrategyFactory indexStrategyFactory() {
return new IndexStrategyFactory();
}
@Bean
public RestHighLevelClientUtils restHighLevelClientUtils() {
RestHighLevelClientUtils restHighLevelClientUtils = new RestHighLevelClientUtils();
if (this.easyEsDynamicProperties == null) {
this.easyEsDynamicProperties = new EasyEsDynamicProperties();
}
Map<String, EasyEsProperties> datasourceMap = this.easyEsDynamicProperties.getDatasource();
if (datasourceMap.isEmpty()) {
// 设置默认数据源,兼容不使用多数据源配置场景的老用户使用习惯
datasourceMap.put(RestHighLevelClientUtils.DEFAULT_DS, this.easyEsProperties);
}
for (String key : datasourceMap.keySet()) {
EasyEsProperties easyEsConfigProperties = datasourceMap.get(key);
RestHighLevelClientUtils.registerRestHighLevelClient(key, RestHighLevelClientUtils
.restHighLevelClient(easyEsConfigProperties));
}
return restHighLevelClientUtils;
}
/**
* 索引策略注册
*
* @return {@link AutoProcessIndexStrategy}
* @author MoJie
*/
@Bean
public AutoProcessIndexStrategy autoProcessIndexSmoothlyStrategy() {
return new AutoProcessIndexSmoothlyStrategy();
}
@Bean
public AutoProcessIndexStrategy autoProcessIndexNotSmoothlyStrategy() {
return new AutoProcessIndexNotSmoothlyStrategy();
}
}

View File

@@ -1,27 +0,0 @@
package org.dromara.easyes.starter.config;
import org.dromara.easyes.core.config.GeneratorConfig;
import org.dromara.easyes.core.toolkit.Generator;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
/**
* 代码生成注册
* @author MoJie
* @since 2.0
*/
@Component
@ConditionalOnProperty(value = "easy-es.enable", havingValue = "true")
public class GeneratorConfiguration extends Generator {
@Autowired
private RestHighLevelClient client;
@Override
public Boolean generate(GeneratorConfig config) {
super.generateEntity(config, this.client);
return Boolean.TRUE;
}
}

View File

@@ -77,6 +77,8 @@ spring:
easy-es:
# 是否开启EE自动配置
enable: false
# 兼容模式
compatible: true
# es连接地址+端口 格式必须为ip:port,如果是集群则可用逗号隔开
address : localhost:9200
# 默认为http