Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master' into prod_test

# Conflicts:
#	src/main/java/cn/cslg/pas/common/config/ElasticSearchClientConfig.java
lwhhszx 1 rok pred
rodič
commit
c563600fc5

+ 28 - 26
src/main/java/cn/cslg/pas/common/config/ElasticSearchClientConfig.java

@@ -14,6 +14,7 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.ssl.SSLContextBuilder;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
@@ -21,15 +22,39 @@ import javax.net.ssl.SSLContext;
 
 
 @Configuration
-public class ElasticSearchClientConfig {
+public class  ElasticSearchClientConfig {
     //配置RestHighLevelClient依赖到spring容器中待用
-
+    @Value("${ES.config}")
+    private String config;
     @Configuration
     public class ElasticSearchConfig {
         //注入IOC容器
+        @Bean
+        public ElasticsearchClient elasticsearchClient() throws Exception {
+            RestClientBuilder builder = RestClient.builder(new HttpHost(config, 9200, "http"));
+            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "Xiaoshi221101"));
+            SSLContext sslContext = SSLContextBuilder.create()
+                    .loadTrustMaterial(new TrustSelfSignedStrategy())
+                    .build();
+            builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider).setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()));
+            RestClient client =builder.build();
+            ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());
+            return new ElasticsearchClient(transport);
+        }
+//                @Bean
+//                public ElasticsearchClient elasticsearchClient() throws Exception {
+//                    RestClientBuilder builder = RestClient.builder(new HttpHost("47.101.137.223", 9200, "http"));
+//                    RestClient client = builder.build();
+//                    ElasticsearchTransport transport = new RestClientTransport(client, new JacksonJsonpMapper());
+//
+//                    return new ElasticsearchClient(transport);
+//                }
+
+
 //        @Bean
 //        public ElasticsearchClient elasticsearchClient() throws Exception {
-//            RestClientBuilder builder = RestClient.builder(new HttpHost("192.168.1.24", 9200, "https"));
+//            RestClientBuilder builder = RestClient.builder(new HttpHost("47.101.137.223", 9200, "http"));
 //            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
 //            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "xiaoshi221101"));
 //            SSLContext sslContext = SSLContextBuilder.create()
@@ -40,28 +65,5 @@ public class ElasticSearchClientConfig {
 //            ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());
 //            return new ElasticsearchClient(transport);
 //        }
-//                @Bean
-//                public ElasticsearchClient elasticsearchClient() throws Exception {
-//                    RestClientBuilder builder = RestClient.builder(new HttpHost("47.101.137.223", 9200, "http"));
-//                    RestClient client = builder.build();
-//                    ElasticsearchTransport transport = new RestClientTransport(client, new JacksonJsonpMapper());
-//
-//                    return new ElasticsearchClient(transport);
-//                }
-
-
-        @Bean
-        public ElasticsearchClient elasticsearchClient() throws Exception {
-            RestClientBuilder builder = RestClient.builder(new HttpHost("47.101.137.223", 9200, "http"));
-            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "xiaoshi221101"));
-            SSLContext sslContext = SSLContextBuilder.create()
-                    .loadTrustMaterial(new TrustSelfSignedStrategy())
-                    .build();
-            builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider).setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()));
-            RestClient client =builder.build();
-            ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());
-            return new ElasticsearchClient(transport);
-        }
     }
 }

+ 5 - 1
src/main/resources/application-dev.yml

@@ -67,4 +67,8 @@ PCSUrl: http://localhost:8871
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
 FMSUrl: http://localhost:8801
-FileSource: 1
+FileSource: 1
+ES:
+  patentVector: patent_vector
+  patent: wxpatent
+  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com

+ 5 - 1
src/main/resources/application-prodNetIn.yml

@@ -33,4 +33,8 @@ OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
 RMSUrl: http://localhost:8872
 FMSUrl: http://localhost:8801
-FileSource: 3
+FileSource: 3
+ES:
+  patentVector: patent_vector
+  patent: wxpatent
+  config: es-cn-em93o8856000ho9e7.elasticsearch.aliyuncs.com