mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-23 20:42:11 +00:00
DATAES-47 - Spring Application(Context) is not getting started up if elasticsearch nodes are not available
This commit is contained in:
parent
d92f4150b7
commit
be1d26eae3
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -25,7 +25,10 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticSearchException;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
import org.springframework.data.domain.*;
|
import org.springframework.data.domain.*;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
@ -45,6 +48,7 @@ import org.springframework.util.Assert;
|
|||||||
public abstract class AbstractElasticsearchRepository<T, ID extends Serializable> implements
|
public abstract class AbstractElasticsearchRepository<T, ID extends Serializable> implements
|
||||||
ElasticsearchRepository<T, ID> {
|
ElasticsearchRepository<T, ID> {
|
||||||
|
|
||||||
|
static final Logger LOGGER = LoggerFactory.getLogger(AbstractElasticsearchRepository.class);
|
||||||
protected ElasticsearchOperations elasticsearchOperations;
|
protected ElasticsearchOperations elasticsearchOperations;
|
||||||
protected Class<T> entityClass;
|
protected Class<T> entityClass;
|
||||||
protected ElasticsearchEntityInformation<T, ID> entityInformation;
|
protected ElasticsearchEntityInformation<T, ID> entityInformation;
|
||||||
@ -63,8 +67,12 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
|||||||
Assert.notNull(metadata);
|
Assert.notNull(metadata);
|
||||||
this.entityInformation = metadata;
|
this.entityInformation = metadata;
|
||||||
setEntityClass(this.entityInformation.getJavaType());
|
setEntityClass(this.entityInformation.getJavaType());
|
||||||
createIndex();
|
try {
|
||||||
putMapping();
|
createIndex();
|
||||||
|
putMapping();
|
||||||
|
} catch (ElasticSearchException exception) {
|
||||||
|
LOGGER.error("failed to load elasticsearch nodes : " + exception.getDetailedMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIndex() {
|
private void createIndex() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user