elasticsearch java无法连接、
问题描述
我在本地启动的ES,使用CURL进行调用是没问题的,但是在代码中无法连接。
Settings settings = Settings.builder().put('cluster.name', 'cluster-tony').build();try { //创建client TransportClient client = new PreBuiltTransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName('192.168.0.230'), 9200)); //搜索数据 GetResponse response = client.prepareGet('blog', 'article', '1').execute().actionGet(); //输出结果 System.out.println(response.getSourceAsString()); //关闭client client.close();} catch (UnknownHostException e) { e.printStackTrace();}
在浏览器中访问的结果:
{ 'name' : '7BaVGc5', 'cluster_name' : 'cluster-tony', 'cluster_uuid' : 'ctTbTQfvTUyzV00JMWPfyA', 'version' : { 'number' : '5.3.0', 'build_hash' : '3adb13b', 'build_date' : '2017-03-23T03:31:50.652Z', 'build_snapshot' : false, 'lucene_version' : '6.4.1' }, 'tagline' : 'You Know, for Search'}
问题解答
回答1:知道原因了,pom中jar重复了
相关文章:
1. windows误人子弟啊2. mysql优化 - MySQL如何为配置表建立索引?3. 实现bing搜索工具urlAPI提交4. 关于mysql联合查询一对多的显示结果问题5. 数据库 - Mysql的存储过程真的是个坑!求助下面的存储过程哪里错啦,实在是找不到哪里的问题了。6. 我在网址中输入localhost/abc.php显示的是not found是为什么呢?7. 如何用笔记本上的apache做微信开发的服务器8. python - linux怎么在每天的凌晨2点执行一次这个log.py文件9. MySQL主键冲突时的更新操作和替换操作在功能上有什么差别(如图)10. 冒昧问一下,我这php代码哪里出错了???
