ElasticSearchConfig.java 766 B

12345678910111213141516171819202122232425262728
  1. package com.pavis.ghjesapi.config;
  2. import org.apache.http.HttpHost;
  3. import org.elasticsearch.client.RestClient;
  4. import org.elasticsearch.client.RestHighLevelClient;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7. /**
  8. * @program: test-es
  9. * @description: ElasticSearchConfig
  10. * @author: Guanzi
  11. * @created: 2021/09/30 16:55
  12. */
  13. @Configuration
  14. public class ElasticSearchConfig {
  15. // 注册 rest高级客户端
  16. @Bean
  17. public RestHighLevelClient restHighLevelClient() {
  18. RestHighLevelClient client = new RestHighLevelClient(
  19. RestClient.builder(
  20. new HttpHost("127.0.0.1", 9200, "http")
  21. )
  22. );
  23. return client;
  24. }
  25. }