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. python - (初学者)代码运行不起来,求指导,谢谢!2. 为什么python中实例检查推荐使用isinstance而不是type?3. mysql里的大表用mycat做水平拆分,是不是要先手动分好,再配置mycat4. window下mysql中文乱码怎么解决??5. sass - gem install compass 使用淘宝 Ruby 安装失败,出现 4046. html5 - H5 SSE的本质是什么?7. javascript - h5上的手机号默认没有识别8. python - 获取到的数据生成新的mysql表9. python的文件读写问题?10. javascript - js 对中文进行MD5加密和python结果不一样。
