gpt4 book ai didi

spring - Spring Boot ElasticSearch端口

转载 作者:行者123 更新时间:2023-12-03 00:33:37 26 4
gpt4 key购买 nike

我刚刚用ElasticSearch编写了一个小的Spring Boot应用程序。
到目前为止效果很好。

无效的是ElasticSearch本身的REST端点。
我只希望它可以玩一点。
这有什么窍门?

2015年5月26日更新:

Elasticsearch版本是1.3.2。

我的main()类:
代码有效,没有错误消息。
但是正如我所说,ElasticSearch的REST API不可用。 netstat上没有列出开放端口:

import org.elasticsearch.client.Client;
import org.elasticsearch.node.NodeBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class SmartSearchRunner implements CommandLineRunner{

@Autowired
private AddressService addressService;

@Override
public void run(String... arg0) throws Exception {
System.out.println("Hello Spring Boot ElasticSearch!");

Address ingo = new Address();
ingo.setId("foo");
ingo.setName("ingo");

addressService.addAddress(ingo);

System.out.println(addressService.getByName("ingo"));
}

public static void main(String[] args) {
SpringApplication.run(SmartSearchRunner.class, args);
}
}

最佳答案

将其放在您的Spring Boot应用程序属性中:

spring.data.elasticsearch.properties.http.enabled = true

关于spring - Spring Boot ElasticSearch端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30401066/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com