Я пытаюсь использовать эластичный поиск в моем веб-приложении.Я использую пружинный ботинок 2.0.6 .Я не добавил ни одного файла конфигурации, упругий поиск автоматически настраивается при весенней загрузке.Я добавил свойства эластичного поиска данных пружин в application.properties, подобные этому
spring-data -asticsearch-3.0.11
asticsearch-5.6.12
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=localhost:9300
spring.data.elasticsearch.properties.node.master: true
spring.data.elasticsearch.properties.node.data: false
spring.data.elasticsearch.properties.node.name: my-node
spring.data.elasticsearch.properties.node.attr.type: hot
spring.data.elasticsearch.properties.http.enabled: true
spring.data.elasticsearch.repositories.enabled=true
Когда я запускаю консоль приложения, показывая
o.elasticsearch.plugins.PluginsService : no modules loaded
o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.index.reindex.ReindexPlugin]
o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.join.ParentJoinPlugin]
o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.percolator.PercolatorPlugin]
o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.script.mustache.MustachePlugin]
o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.transport.Netty4Plugin]
o.s.d.e.c.TransportClientFactoryBean : Adding transport node : 127.0.0.1:9300
Я добавил один простой пример для демонстрации, но я получаю эту ошибку
.d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{zYXxPcpaQ_6I9GI2yID8cQ}{localhost}{127.0.0.1:9300}]
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loaders':
Invocation of init method failed; nested exception is NoNodeAvailableException
[None of the configured nodes are available: [{#transport#-1}{zYXxPcpaQ_6I9GI2yID8cQ}{localhost}{127.0.0.1:9300}]]
это пример, который я использовал
Users.java
@Document(indexName = "users", type = "users", shards = 1, replicas = 0, refreshInterval = "-1")
public class Users {
private String name;
private Long id;
private String teamName;
private Long salary;
Loaders.java
@Component
public class Loaders {
@Autowired
ElasticsearchOperations operations;
@Autowired
UsersRepository usersRepository;
@PostConstruct
@Transactional
public void loadAll(){
operations.putMapping(Users.class);
System.out.println("Loading Data");
usersRepository.saveAll(getData());
System.out.printf("Loading Completed");
}
private List<Users> getData() {
List<Users> userses = new ArrayList<>();
userses.add(new Users("Ajay",123L, "Accounting", 12000L));
userses.add(new Users("Jaga",1234L, "Finance", 22000L));
userses.add(new Users("Thiru",1235L, "Accounting", 12000L));
return userses;
}
}
UsersRepository.java
public interface UsersRepository extends ElasticsearchRepository<Users, Long> {
List<Users> findByName(String text);
List<Users> findBySalary(Long salary);
}
Почему я получаю ошибку?Есть ли какое-либо другое свойство, которое я должен использовать?