diff --git a/persistence-modules/elasticsearch/jest/pom.xml b/persistence-modules/elasticsearch/jest/pom.xml index e1bb08d182..7027f70900 100644 --- a/persistence-modules/elasticsearch/jest/pom.xml +++ b/persistence-modules/elasticsearch/jest/pom.xml @@ -2,52 +2,30 @@ 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.5.RELEASE - - com.baeldung.jest jest-demo 0.0.1-SNAPSHOT jest-demo - Demo project for Spring Boot + Demo project for Jest Client for Elasticsearch + 8 + 1.8 + 1.8 - - org.springframework.boot - spring-boot-starter - + io.searchbox jest 6.3.1 - - - org.springframework.boot - spring-boot-starter-test - test - com.fasterxml.jackson.core jackson-databind 2.9.6 - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestClientConfiguration.java b/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestClientConfiguration.java deleted file mode 100644 index a010c0f76e..0000000000 --- a/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestClientConfiguration.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.jest; - -import io.searchbox.client.JestClient; -import io.searchbox.client.JestClientFactory; -import io.searchbox.client.config.HttpClientConfig; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class JestClientConfiguration { - - @Value("${elastic.url:http://localhost:9200}") - private String elasticUrl; - - /** - * Create a JEST client bean. - * @return JestClient - */ - @Bean - public JestClient jestClient() - { - JestClientFactory factory = new JestClientFactory(); - factory.setHttpClientConfig( - new HttpClientConfig.Builder(elasticUrl) - .multiThreaded(true) - .defaultMaxTotalConnectionPerRoute(2) - .maxTotalConnection(20) - .build()); - return factory.getObject(); - } -} diff --git a/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestDemoApplication.java b/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestDemoApplication.java index 7eb53ff25a..e4c8ef51be 100644 --- a/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestDemoApplication.java +++ b/persistence-modules/elasticsearch/jest/src/main/java/com/baeldung/jest/JestDemoApplication.java @@ -5,8 +5,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.searchbox.client.JestClient; +import io.searchbox.client.JestClientFactory; import io.searchbox.client.JestResult; import io.searchbox.client.JestResultHandler; +import io.searchbox.client.config.HttpClientConfig; import io.searchbox.core.*; import io.searchbox.indices.CreateIndex; import io.searchbox.indices.IndicesExists; @@ -15,21 +17,16 @@ import io.searchbox.indices.aliases.ModifyAliases; import io.searchbox.indices.aliases.RemoveAliasMapping; import io.searchbox.indices.mapping.PutMapping; import io.searchbox.indices.settings.GetSettings; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ApplicationContext; import java.io.IOException; import java.util.*; -@SpringBootApplication public class JestDemoApplication { public static void main(String[] args) throws IOException { - ApplicationContext context = SpringApplication.run(JestDemoApplication.class, args); // Demo the JestClient - JestClient jestClient = context.getBean(JestClient.class); + JestClient jestClient = jestClient(); // Check an index JestResult result = jestClient.execute(new IndicesExists.Builder("employees").build()); @@ -160,4 +157,15 @@ public class JestDemoApplication { }); } + private static JestClient jestClient() + { + JestClientFactory factory = new JestClientFactory(); + factory.setHttpClientConfig( + new HttpClientConfig.Builder("http://localhost:9200") + .multiThreaded(true) + .defaultMaxTotalConnectionPerRoute(2) + .maxTotalConnection(20) + .build()); + return factory.getObject(); + } }