Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spring:
- datasource:
- url: ${vcap.services.es-small.credentials.host}
- username: ${vcap.services.es-small.credentials.username}
- password: ${vcap.services.es-small.credentials.password}
- 2018-10-12T22:14:58.72-0700 [APP/PROC/WEB/0] OUT Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in class path resource [com/javatechstack/datajpa/ElasticSearchConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.Client]: Factory method 'client' threw exception; nested exception is java.net.UnknownHostException: http://d412092.service.dc1.a9s-elasticsearch-consul:9200: Name or service not known
- {
- "VCAP_SERVICES": {
- "a9s-elasticsearch6": [
- {
- "credentials": {
- "dns_servers": [
- "192.168.24.4",
- "192.168.24.5",
- "192.168.24.6"
- ],
- "host": [
- "http://d412092.service.dc1.a9s-elasticsearch-consul:9200"
- ],
- "host_ip": [
- "http://192.168.28.8:9200"
- ],
- "password": "a9s5d93c1563f60d0702e6ca24928993aae76948a00",
- "username": "a9s96eb080f8089c5fa32f214e9d8e7c6752de7db0a"
- },
- "label": "a9s-elasticsearch6",
- "name": "es-small",
- "plan": "elasticsearch-single-small",
- "provider": null,
- "syslog_drain_url": null,
- "tags": [
- "searchengine"
- ],
- "volume_mounts": []
- }
- ]
- }
- }
- public class ElasticSearchConfig {
- //@Value("${elasticsearch.host}")
- @Value("${vcap.services.es-small.credentials.host}")
- private String EsHost;
- /*
- //@Value("${elasticsearch.port}")
- @Value("${vcap.services.es-small.credentials.username}")
- private int EsPort;
- //@Value("${elasticsearch.clustername}")
- @Value("${vcap.services.es-small.credentials.password}")
- private String EsClusterName;
- */
- @Bean
- public Client client() throws Exception {
- return new PreBuiltTransportClient(Settings.EMPTY)
- .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(EsHost), 9300));
- }
- @Bean
- public ElasticsearchOperations elasticsearchTemplate() throws Exception {
- return new ElasticsearchTemplate(client());
- }
- }
Add Comment
Please, Sign In to add comment