SpringBoot连接elasticsearch异常
2018-09-11 16:03:43.692 ERROR 8684 --- [ main] o.s.boot.SpringApplication : Application run failed java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:826) [spring-boot-2.1.0.M2.jar:2.1.0.M2]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:807) [spring-boot-2.1.0.M2.jar:2.1.0.M2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:345) [spring-boot-2.1.0.M2.jar:2.1.0.M2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1269) [spring-boot-2.1.0.M2.jar:2.1.0.M2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1257) [spring-boot-2.1.0.M2.jar:2.1.0.M2]
at sample.data.elasticsearch.SampleElasticsearchApplication.main(SampleElasticsearchApplication.java:68) [classes/:na]
Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{Yg5eMgPdSqiRy7T4al93qw}{127.0.0.1}{127.0.0.1:9300}]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:378) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:405) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:394) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.getSearchResponse(ElasticsearchTemplate.java:942) ~[spring-data-elasticsearch-3.1.0.RC2.jar:3.1.0.RC2]
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.doScroll(ElasticsearchTemplate.java:807) ~[spring-data-elasticsearch-3.1.0.RC2.jar:3.1.0.RC2]
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.startScroll(ElasticsearchTemplate.java:821) ~[spring-data-elasticsearch-3.1.0.RC2.jar:3.1.0.RC2]
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.delete(ElasticsearchTemplate.java:718) ~[spring-data-elasticsearch-3.1.0.RC2.jar:3.1.0.RC2]
at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.deleteAll(AbstractElasticsearchRepository.java:257) ~[spring-data-elasticsearch-3.1.0.RC2.jar:3.1.0.RC2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_05]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_05]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor$$Lambda$1251/56840345.get(Unknown Source) ~[na:na]
at org.springframework.data.repository.util.QueryExecutionConverters$$Lambda$1250/1996449989.apply(Unknown Source) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.0.RC2.jar:2.1.0.RC2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.0.RC2.jar:5.1.0.RC2]
at com.sun.proxy.$Proxy44.deleteAll(Unknown Source) ~[na:na]
at sample.data.elasticsearch.SampleElasticsearchApplication.run(SampleElasticsearchApplication.java:35) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:823) [spring-boot-2.1.0.M2.jar:2.1.0.M2]
... 5 common frames omitted 2018-09-11 16:03:43.695 INFO 8684 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
解决办法注释掉elasticsearch配置文件中 cluster.name。