!148 修复项目启动时可能会造成es client must not be null的问题
Merge pull request !148 from OceansDeep/feature/pg
This commit is contained in:
commit
363dbd3a7f
@ -16,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -69,11 +68,6 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("elasticsearchRestTemplate")
|
|
||||||
public ElasticsearchRestTemplate elasticsearchRestTemplate() {
|
|
||||||
return new ElasticsearchRestTemplate(this.client);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpHost[] getHttpHosts() {
|
private HttpHost[] getHttpHosts() {
|
||||||
List<String> clusterNodes = elasticsearchProperties.getClusterNodes();
|
List<String> clusterNodes = elasticsearchProperties.getClusterNodes();
|
||||||
HttpHost[] httpHosts = new HttpHost[clusterNodes.size()];
|
HttpHost[] httpHosts = new HttpHost[clusterNodes.size()];
|
||||||
|
@ -14,10 +14,9 @@ import org.elasticsearch.index.query.QueryBuilders;
|
|||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHit;
|
import org.springframework.data.elasticsearch.core.SearchHit;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||||
@ -42,8 +41,7 @@ public class SystemLogServiceImpl implements SystemLogService {
|
|||||||
* ES
|
* ES
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("elasticsearchRestTemplate")
|
private ElasticsearchOperations restTemplate;
|
||||||
private ElasticsearchRestTemplate restTemplate;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveLog(SystemLogVO systemLogVO) {
|
public void saveLog(SystemLogVO systemLogVO) {
|
||||||
|
@ -53,8 +53,7 @@ import org.elasticsearch.script.Script;
|
|||||||
import org.elasticsearch.script.ScriptType;
|
import org.elasticsearch.script.ScriptType;
|
||||||
import org.mybatis.spring.MyBatisSystemException;
|
import org.mybatis.spring.MyBatisSystemException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
|
||||||
import org.springframework.data.elasticsearch.core.SearchHit;
|
import org.springframework.data.elasticsearch.core.SearchHit;
|
||||||
import org.springframework.data.elasticsearch.core.SearchPage;
|
import org.springframework.data.elasticsearch.core.SearchPage;
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||||
@ -116,8 +115,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("elasticsearchRestTemplate")
|
private ElasticsearchOperations restTemplate;
|
||||||
private ElasticsearchRestTemplate restTemplate;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -36,10 +36,9 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
|||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHitSupport;
|
import org.springframework.data.elasticsearch.core.SearchHitSupport;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||||
import org.springframework.data.elasticsearch.core.SearchPage;
|
import org.springframework.data.elasticsearch.core.SearchPage;
|
||||||
@ -73,8 +72,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
|||||||
* ES
|
* ES
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("elasticsearchRestTemplate")
|
private ElasticsearchOperations restTemplate;
|
||||||
private ElasticsearchRestTemplate restTemplate;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EsGoodsIndexService esGoodsIndexService;
|
private EsGoodsIndexService esGoodsIndexService;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user