嗨,朋友们,我正在用elastic search开发spring boot项目,我已经在本地机器上安装了elastic search,我已经在elastic search中安装了Head插件。我的弹性搜索设置正确,显示绿色标志。我的项目中的application-dev.yml文件如下:
server:
port: 8080
liquibase:
context: dev
spring:
profiles:
active: dev
datasource:
dataSourceClassName: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:jhipster;DB_CLOSE_DELAY=-1
databaseName:
serverName:
username:
password:
jpa:
database-platform: com.aquevix.demo.domain.util.FixedH2Dialect
database: H2
openInView: false
show_sql: true
generate-ddl: false
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
data:
elasticsearch:
cluster-name: elasticsearch
cluster-nodes: localhost:9200
messages:
cache-seconds: 1
thymeleaf:
mode: XHTML
cache: false
activemq:
broker-url: tcp://localhost:61616
metrics:
jmx.enabled: true
spark:
enabled: false
host: localhost
port: 9999
graphite:
enabled: false
host: localhost
port: 2003
prefix: TestApollo
cache:
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 16MElastic search服务正在我的机器上运行,但是当我尝试保存entity时,首先在mysql中保存entity,然后使用elastic search repository在elastic search中保存entity,但在将entity保存到elastic时抛出错误:
Hibernate: insert into EMPLOYEE (id, rollno) values (null, ?)
[ERROR] com.aquevix.demo.aop.logging.LoggingAspect - Exception in com.aquevix.demo.web.rest.EmployeeResource.create() with cause = null
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:298) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:214) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:105) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.client.support.AbstractClient.index(AbstractClient.java:94) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.client.transport.TransportClient.index(TransportClient.java:331) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.action.index.IndexRequestBuilder.doExecute(IndexRequestBuilder.java:313) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91) ~[elasticsearch-1.3.2.jar:na]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65) ~[elasticsearch-1.3.2.jar:na]
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.index(ElasticsearchTemplate.java:431) ~[spring-data-elasticsearch-1.1.3.RELEASE.jar:na]
at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.save(AbstractElasticsearchRepository.java:138) ~[spring-data-elasticsearch-1.1.3.RELEASE.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]我也使用了9300端口而不是9200端口,但是什么都不能工作。我已经尝试了所有的方法,但我能找到解决方案,请帮帮我!
发布于 2015-11-06 12:50:48
我发现ES2.0解决方案不能正常工作,所以我重新安装了ES1.7.3,现在它在我的情况下是有效的。complete details here!
发布于 2016-07-27 19:10:56
我和你有同样的问题,使用Jhipster也有同样的问题。正如前面提到的,一种可能的解决方案是降级elasticsearch实例,但如果你不想降级,下面是我使用的方法:
将
手动更新 ElasticsearchTemplate
如果您需要更多信息,请查看此帖子:http://ignaciosuay.com/how-to-connect-spring-boot-to-elasticsearch-2-x-x/
发布于 2016-05-17 12:41:10
您似乎正在使用JHipster (如果我可以补充的话,这是一个很棒的工具集),它使用
org.springframework.boot:spring-boot-starter-data-elasticsearch:-> 1.3.3版本
这只适用于2.0版本以下的ElasticSearch,所以只需安装ElasticSearch 1.7.3并运行代码即可
https://stackoverflow.com/questions/33543253
复制相似问题