elasticsearch java無法連接、
問題描述
我在本地啟動的ES,使用CURL進(jìn)行調(diào)用是沒問題的,但是在代碼中無法連接。
Settings settings = Settings.builder().put('cluster.name', 'cluster-tony').build();try { //創(chuàng)建client TransportClient client = new PreBuiltTransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName('192.168.0.230'), 9200)); //搜索數(shù)據(jù) GetResponse response = client.prepareGet('blog', 'article', '1').execute().actionGet(); //輸出結(jié)果 System.out.println(response.getSourceAsString()); //關(guān)閉client client.close();} catch (UnknownHostException e) { e.printStackTrace();}
在瀏覽器中訪問的結(jié)果:
{ '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重復(fù)了
相關(guān)文章:
1. windows誤人子弟啊2. php傳對應(yīng)的id值為什么傳不了啊有木有大神會的看我下方截圖3. 如何用筆記本上的apache做微信開發(fā)的服務(wù)器4. python - linux 下用wsgifunc 運(yùn)行web.py該如何修改代碼5. 關(guān)于mysql聯(lián)合查詢一對多的顯示結(jié)果問題6. 實現(xiàn)bing搜索工具urlAPI提交7. 冒昧問一下,我這php代碼哪里出錯了???8. mysql優(yōu)化 - MySQL如何為配置表建立索引?9. MySQL主鍵沖突時的更新操作和替換操作在功能上有什么差別(如圖)10. 數(shù)據(jù)庫 - Mysql的存儲過程真的是個坑!求助下面的存儲過程哪里錯啦,實在是找不到哪里的問題了。
