import errors in maven project

1.7k views Asked by At

Getting import can not be resolved errors in maven project even though all the required dependencies have been added to the pom.xml. Here are the imports which are getting errored:

import org.apache.hadoop.fs.CreateFlag;
import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.Options;
import org.apache.hadoop.fs.Options.CreateOpts;

And these are the dependencies that are there in pom.xml

<dependencies>
  <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common -->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>2.7.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-auth</artifactId>
            <version>2.7.1</version>
        </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-core</artifactId>
       <version>1.2.1</version>
    </dependency>   
  </dependencies>

Can someone please point out what could possibly be going wrong?

Thanks in advance!!

2

There are 2 answers

0
user3400887 On BEST ANSWER

I tried all the possible options like removing old .m2 directory, update project, checked settings.xml etc but none of them seemed to help. So I finally installed the eclipse again and it worked! Seems like there was something wrong with the IDE but not sure what exactly was wrong.

Thanks everyone for responding with the possible options.

0
mikey On

You can try out different solutions: - Try another version of the Hadoop libraries - Delete the complete .m2 repository in your user folder and redownload the libraries - Check if your project is configured as a Maven project in your IDE

Good luck!