修复一个项目启动时可能会造成es client must not be null的问题
This commit is contained in:
		
							parent
							
								
									9f965c4e56
								
							
						
					
					
						commit
						4c1ae8c3cc
					
				| @ -16,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; | ||||
| import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; | ||||
| 
 | ||||
| import javax.annotation.PreDestroy; | ||||
| import java.io.IOException; | ||||
| @ -69,11 +68,6 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration { | ||||
|         return client; | ||||
|     } | ||||
| 
 | ||||
|     @Bean("elasticsearchRestTemplate") | ||||
|     public ElasticsearchRestTemplate elasticsearchRestTemplate() { | ||||
|         return new ElasticsearchRestTemplate(this.client); | ||||
|     } | ||||
| 
 | ||||
|     private HttpHost[] getHttpHosts() { | ||||
|         List<String> clusterNodes = elasticsearchProperties.getClusterNodes(); | ||||
|         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.SortOrder; | ||||
| 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.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.SearchHits; | ||||
| import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; | ||||
| @ -42,8 +41,7 @@ public class SystemLogServiceImpl implements SystemLogService { | ||||
|      * ES | ||||
|      */ | ||||
|     @Autowired | ||||
|     @Qualifier("elasticsearchRestTemplate") | ||||
|     private ElasticsearchRestTemplate restTemplate; | ||||
|     private ElasticsearchOperations restTemplate; | ||||
| 
 | ||||
|     @Override | ||||
|     public void saveLog(SystemLogVO systemLogVO) { | ||||
|  | ||||
| @ -53,8 +53,7 @@ import org.elasticsearch.script.Script; | ||||
| import org.elasticsearch.script.ScriptType; | ||||
| import org.mybatis.spring.MyBatisSystemException; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | ||||
| 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.SearchPage; | ||||
| import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; | ||||
| @ -116,8 +115,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements | ||||
|     @Autowired | ||||
|     private RocketmqCustomProperties rocketmqCustomProperties; | ||||
|     @Autowired | ||||
|     @Qualifier("elasticsearchRestTemplate") | ||||
|     private ElasticsearchRestTemplate restTemplate; | ||||
|     private ElasticsearchOperations restTemplate; | ||||
| 
 | ||||
|     @Override | ||||
|     public void init() { | ||||
| @ -504,7 +502,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements | ||||
|     /** | ||||
|      * 从索引中删除指定促销活动id的促销活动 | ||||
|      * | ||||
|      * @param goodsIndex  索引 | ||||
|      * @param goodsIndex    索引 | ||||
|      * @param promotionsKey 促销活动key | ||||
|      */ | ||||
|     private UpdateRequest removePromotionByPromotionKey(EsGoodsIndex goodsIndex, String promotionsKey) { | ||||
|  | ||||
| @ -36,10 +36,9 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; | ||||
| import org.elasticsearch.search.sort.SortBuilders; | ||||
| import org.elasticsearch.search.sort.SortOrder; | ||||
| 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.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.SearchHits; | ||||
| import org.springframework.data.elasticsearch.core.SearchPage; | ||||
| @ -73,8 +72,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { | ||||
|      * ES | ||||
|      */ | ||||
|     @Autowired | ||||
|     @Qualifier("elasticsearchRestTemplate") | ||||
|     private ElasticsearchRestTemplate restTemplate; | ||||
|     private ElasticsearchOperations restTemplate; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private EsGoodsIndexService esGoodsIndexService; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 paulGao
						paulGao