由于spring引导问题,所有配置的节点都不可用

由于spring引导问题,所有配置的节点都不可用,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,嗨,朋友们,我正在用elasticsearch开发spring boot项目,我已经在本地机器上安装了elasticsearch,并且在elasticsearch中安装了Head插件。我的弹性搜索设置正确,显示绿色标志。 我的项目中的application-dev.yml文件如下: server: port: 8080 liquibase: context: dev spring: profiles: active: dev datasourc

嗨,朋友们,我正在用
elasticsearch
开发spring boot项目,我已经在本地机器上安装了elasticsearch,并且在elasticsearch中安装了
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: 16M
弹性搜索服务正在我的计算机上运行,但当我尝试先将实体保存在mysql中,然后使用
Elastic search repository
在弹性搜索中保存实体时,将实体保存到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
,但没有任何功能。我尝试了所有方法,但都能找到解决方案,请帮助

我发现解决方案ES2.0无法正常工作,因此我重新安装了ES1.7.3,现在它在我的情况下可以正常工作

您似乎正在使用JHipster(如果我可以补充的话,这是一个很棒的工具集),它使用

org.springframework.boot:springbootstarter数据弹性搜索:-> 1.3.3.1发布


这只适用于2.0以下的ElasticSearch,因此只需安装ElasticSearch 1.7.3并运行代码即可

我遇到了与您相同的问题,也使用了Jhipster。如前所述,一种可能的解决方案是降级elasticsearch实例,但如果您不想降级,下面是它对我的作用:

  • 将spring boot更新到最新版本(>1.4.0.RC1)
  • 手动配置ElasticsearchTemplate,而不是使用自动配置
如果您需要更多信息,请查看此帖子:

我遇到了这个错误,对我来说,原因是我使用了不正确的集群名称

解决此错误的步骤:

  • 确保Spring数据Elasticsearch与您打算使用的Elasticsearch版本兼容。项目自述文件中有一个表格,对应于Spring数据Elasticsearch版本和Elasticsearch版本:

    在我的例子中,我使用的是Spring数据Elasticsearch 3.0.7。根据表,我需要使用Elasticsearch 5.5.0,但我发现Spring数据Elasticsearch 3.0.7似乎也与Elasticsearch 5.6.x兼容

  • 确保
    spring.data.elasticsearch.cluster nodes
    属性指定elasticsearch群集使用本机elasticsearch传输协议进行通信时使用的端口

    默认情况下,Elasticsearch侦听两个端口9200和9300。端口9200用于使用RESTful API进行通信。端口9300用于使用传输协议进行通信:

    SpringDataElasticSearch使用的Java客户端希望使用传输协议(默认为9300)进行通信

  • 确保
    spring.data.elasticsearch.cluster name
    属性指定了正确的集群名称

    如果未专门设置此属性,则默认设置为“elasticsearch”

    您可以使用RESTful API查找Elasticsearch集群名称:
    curl-XGET'http://localhost:9200/?pretty“

    此命令将打印类似于以下内容的内容:

    { "name" : "XXXXXXX", "cluster_name" : "some_cluster_name", "cluster_uuid" : "XXXXXXXXXXXXXXXXXXXXXX", "version" : { "number" : "5.6.10", "build_hash" : "b727a60", "build_date" : "2018-06-06T15:48:34.860Z", "build_snapshot" : false, "lucene_version" : "6.6.1" }, "tagline" : "You Know, for Search" } { “名称”:“XXXXXXX”, “集群名称”:“一些集群名称”, “群集uuid”:“XXXXXXXXXXXXXXXXXXXXXXXXXX”, “版本”:{ “编号”:“5.6.10”, “构建散列”:“b727a60”, “建造日期”:“2018-06-06T15:48:34.860Z”, “生成快照”:false, “lucene_版本”:“6.6.1” }, “标语”:“你知道,搜索” } 确保将
    spring.data.elasticsearch.cluster name
    属性的值设置为“cluster\u name”所示的相同字符串


  • 我在这里也遇到了同样的问题,同样是关于Elasticsearch 2.x,您应该在您的问题中指定它。链接中的这部分帮助了我:
    注意:如果您想将Elasticsearch与java或spring boot结合使用,请不要将9200用作端口,因为9200端口用于http协议,9300端口仅用于tcp协议