elasticsearch java無法連接、
問題描述
我在本地啟動的ES,使用CURL進行調(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. node.js - mysql如何通過knex查詢今天和七天內(nèi)的匯總數(shù)據(jù)2. shell - Update query wrong in MySQL3. javascript - 用jsonp抓取qq音樂總是說回調(diào)函數(shù)沒有定義4. mysql 插入數(shù)值到特定的列一直失敗5. mysql 怎么做到update只更新一行數(shù)據(jù)?6. javascript - 新浪微博網(wǎng)頁版的字?jǐn)?shù)限制是怎么做的7. 怎么在網(wǎng)頁中設(shè)置圖片進行左右滑動8. 360瀏覽器與IE瀏覽器有何區(qū)別???9. sublime可以用其他編譯器替換嗎?10. python - 在使用Pycharm時經(jīng)常看到如下的樣式,小括號里紅色的部分是什么意思呢?
