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. python - 《flask web 開發(fā)》一書,數(shù)據(jù)庫中多對多關(guān)系的實(shí)現(xiàn)問題?2. 關(guān)于phpstudy設(shè)置主從數(shù)據(jù)庫3. mysql - 我用SQL語句 更新 行的時候,發(fā)現(xiàn)全部 中文都被清空了,請問怎么解決?4. centos7 編譯安裝 Python 3.5.1 失敗5. python3.x - python3.5使用pyinstaller打包報錯找不到libpython3.5mu.so.1.0等文件求解?6. phpStudy2017輕巧版mysql無法啟動7. 為什么我輸入了refresh不會跳轉(zhuǎn)?請教大神支招!8. 為什么顯示數(shù)據(jù)丟失呢9. 為什么我寫的PHP不行10. MySQL在什么情況下會被堵死?
