1

I'm a beginner trying to access elasticsearch through JAVA with eclipse, but after following the instructions available at this guide , eclipse is not able to import packages like org.elasticsearch.node.* and I haven't been able to continue.

This is my first time with Maven, and the configurations might be wrong.

This is my pom.xml file:

<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>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>elasticsearch</name>
      <url>http://maven.apache.org</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>

      <dependencies>

        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>${es.version}</version>
        </dependency>

        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </project>

I can access elasticsearch through a terminal or browser, but not with eclipse. What step I am missing?

2 Answers 2

2

You haven't defined es.version in your properties section. mvn install should have thrown errors because it can't download elasticsearch dependencies. I think following change to your pom would work.

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <es.version>0.90.3</es.version>
</properties>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks it worked. I just changed to version 1.0.0 because I'm using that.
Great. Have fun with es 1.0.0
0

Here is the pom.xml in my eclipse Maven project. It works. Just for you reference.

    <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>elastic.mapper</groupId>
      <artifactId>importer</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>importer</name>
      <url>http://maven.apache.org</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>

      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>2.0.0</version>
    </dependency>
      </dependencies>

    </project>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.