feat: easy-es关于spring springboot2/3 solon的适配完成

This commit is contained in:
阿杰 2025-01-09 19:43:40 +08:00
parent 8d84736714
commit 1da650827a
8 changed files with 17 additions and 1062 deletions

View File

@ -52,40 +52,4 @@ public class EsAutoConfiguration {
return new EasyEsDynamicProperties();
}
@Bean
public IndexStrategyFactory indexStrategyFactory() {
return new IndexStrategyFactory();
}
@Bean
public RestHighLevelClientUtils restHighLevelClientUtils() {
RestHighLevelClientUtils restHighLevelClientUtils = new RestHighLevelClientUtils();
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

@ -70,7 +70,8 @@
{
"name": "easy-es.global-config.i-kun-mode",
"description": "for fun, whether to print love chinese `kung fu` mode 是否开启爱坤(小黑子)模式 开启后日志将进入疯狂状态, 后期也会在此特殊模式下提供更多趣味化及傻瓜功能 让编码不仅简单,还有趣!.",
"type": "java.lang.Boolean"
"type": "java.lang.Boolean",
"sourceType": "org.dromara.easyes.common.property.EasyEsProperties"
},
{
"defaultValue": "MANUAL",

View File

@ -1,4 +1,5 @@
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.dromara.easyes.starter.EsAutoConfiguration,\
org.dromara.easyes.spring.config.EasyEsConfiguration,\
org.dromara.easyes.starter.config.GeneratorConfiguration

View File

@ -0,0 +1,3 @@
org.dromara.easyes.starter.EsAutoConfiguration
org.dromara.easyes.starter.config.GeneratorConfiguration
org.dromara.easyes.spring.config.EasyEsConfiguration

View File

@ -31,7 +31,10 @@ public class EsAutoConfiguration {
@Bean
public EasyEsDynamicProperties easyEsDynamicProperties(
@Inject(value = "${easy-es.dynamic}", autoRefreshed = true) EasyEsDynamicProperties dynamicProperties) {
@Inject(value = "${easy-es.dynamic:}", autoRefreshed = true) EasyEsDynamicProperties dynamicProperties) {
if (dynamicProperties == null) {
return new EasyEsDynamicProperties();
}
return dynamicProperties;
}

View File

@ -9,6 +9,7 @@ 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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
@ -27,6 +28,12 @@ public class EasyEsConfiguration implements InitializingBean {
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");

View File

@ -1,11 +0,0 @@
easy-es.keep-alive-millis=18000
easy-es.address=198.163.192.11:9200
easy-es.global-config.IKunMode=true
easy-es.global-config.process-index-mode=manual
easy-es.global-config.async-process-index-blocking=true
easy-es.global-config.print-dsl=true
easy-es.global-config.db-config.map-underscore-to-camel-case=true
easy-es.global-config.db-config.id-type=customize
easy-es.global-config.db-config.field-strategy=not_empty
easy-es.global-config.db-config.refresh-policy=immediate
easy-es.global-config.db-config.enable-track-total-hits=true