Guest User

Untitled

a guest
Oct 13th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. spring:
  2. datasource:
  3. url: ${vcap.services.es-small.credentials.host}
  4. username: ${vcap.services.es-small.credentials.username}
  5. password: ${vcap.services.es-small.credentials.password}
  6.  
  7. 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
  8.  
  9. {
  10. "VCAP_SERVICES": {
  11. "a9s-elasticsearch6": [
  12. {
  13. "credentials": {
  14. "dns_servers": [
  15. "192.168.24.4",
  16. "192.168.24.5",
  17. "192.168.24.6"
  18. ],
  19. "host": [
  20. "http://d412092.service.dc1.a9s-elasticsearch-consul:9200"
  21. ],
  22. "host_ip": [
  23. "http://192.168.28.8:9200"
  24. ],
  25. "password": "a9s5d93c1563f60d0702e6ca24928993aae76948a00",
  26. "username": "a9s96eb080f8089c5fa32f214e9d8e7c6752de7db0a"
  27. },
  28. "label": "a9s-elasticsearch6",
  29. "name": "es-small",
  30. "plan": "elasticsearch-single-small",
  31. "provider": null,
  32. "syslog_drain_url": null,
  33. "tags": [
  34. "searchengine"
  35. ],
  36. "volume_mounts": []
  37. }
  38. ]
  39. }
  40. }
  41.  
  42. public class ElasticSearchConfig {
  43.  
  44. //@Value("${elasticsearch.host}")
  45. @Value("${vcap.services.es-small.credentials.host}")
  46. private String EsHost;
  47. /*
  48. //@Value("${elasticsearch.port}")
  49. @Value("${vcap.services.es-small.credentials.username}")
  50. private int EsPort;
  51.  
  52. //@Value("${elasticsearch.clustername}")
  53. @Value("${vcap.services.es-small.credentials.password}")
  54. private String EsClusterName;
  55. */
  56. @Bean
  57. public Client client() throws Exception {
  58.  
  59. return new PreBuiltTransportClient(Settings.EMPTY)
  60. .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(EsHost), 9300));
  61. }
  62.  
  63. @Bean
  64. public ElasticsearchOperations elasticsearchTemplate() throws Exception {
  65. return new ElasticsearchTemplate(client());
  66. }
  67. }
Add Comment
Please, Sign In to add comment