在Intelij Idea

时间:2015-05-19 14:47:03

标签: maven intellij-idea elasticsearch pom.xml

您好我正在尝试编写一个简单的程序来实现弹性搜索客户端。我正在使用Intellij Idea IDE和maven。

我创建了一个maven项目,在〜/ Desktop / ESearch / src / main / java / dhruv / dev / elastic下,我创建了以下java文件。

我只想尝试通过elasticsearch GET-API检索结果。我已经使用REST-API索引,并且可以使用marvel插件检索它们。

package dhruv.dev.elastic;

import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import java.io.IOException;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;

public class ESClient
{
    public static void search()throws IOException
    {
        Node node;
        node = nodeBuilder().clusterName("Pikachu").node();
        Client client;
        client = node.client();
        GetResponse response;
        response= client.prepareGet("twitter", "tweet", "1").execute() .actionGet();
        System.out.println(response.toString());

    }
    public static void main()throws IOException
    {
        search();

    }

}

在我的pom.xml中,有以下代码,

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>dhruv</groupId>
    <artifactId>Search</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>1.4.0</version>
        </dependency>

    </dependencies>

    <build>
    <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
    </plugins>
    </build>
</project>

代码编译正常。当我运行它时,会出现如下错误: -

  
    

建立失败[信息]
    -------------------------------------------------- ----------------------
[INFO]总时间:5.319s [INFO]完成时间:5月19日星期二19:39:31     IST
2015 [INFO]最终记忆:12M / 220M [INFO]
    -------------------------------------------------- ----------------------
[ERROR]无法执行目标     org.apache.maven.plugins:行家 - 部署 - 插件:2.7:部署     项目上的(默认部署)搜索:部署失败:存储库     在distributionManagement中的POM中未指定元素     元件

  

究竟是什么,我无法弄明白。我读了一点here但它与我的项目有什么关系,因为它只是为了练习而不是为了部署。我知道我可能听起来很愚蠢,但我无法对此有任何具体的想法。

0 个答案:

没有答案