优化代码,增加buyer启动时检测es索引存在,如不存在则自动创建
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package cn.lili.init;
|
||||
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2022/6/9
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EsGoodsIndexInitRunner implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private EsGoodsIndexService esGoodsIndexService;
|
||||
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
try {
|
||||
esGoodsIndexService.initIndex();
|
||||
} catch (Exception e) {
|
||||
log.error("检测ES商品索引失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user