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!!
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!
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.
Related
I unable to import Java jwt 3.10.0. in my spring project. Actually I was trying before version 3.15.0 but it was giving me an error in pom.xml
"Dependency 'com.auth0:java-jwt:3.15.0' not found"
anyway I then move with version 3.10.0 which is accepted in pom.xml, but it doesn't importing in project, although I've many updated Maven, restart Intellj.
Grateful if anyone can advise.
Dependency in pom.xml
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.0</version>
</dependency>
I am using Netbeans and I've created java project with Maven. I added this dependency.
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.2</version>
</dependency>
It worked, I could import com.squareup.okhttp.*. After seeing some code on the web I realized that many people are using the version 3+. I tried to change the package to:
updated
I've typed groupid wrongly in the question "com.squareup.okhttp" but in my code it was right "com.squareup.okhttp3".
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.0</version>
But I couldn't import com.squareup.okhttp3 ( package com.squareup does not exist). Why? I am new to the Java language itself and all the IDEs and tools that support it.
The import is just okhttp3: "import okhttp3" without com.square.
The correct coordinates for okhttp3 are:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.1</version>
</dependency>
Note that the groupId has changed from com.squareup.okhttp to com.squareup.okhttp3.
So, if you update your pom.xml, replacing what you had for okhttp with what I posted above then you'll be able to resolve the okhttp classes.
For future reference you can find the okhttp artifacts on Maven Central.
Okhttp3 does not exist is due to a bug in Intellij IDE; however, there is a get-around:
Place your 'com.squareup.okhttp3' dependency block at the end of the 'dependencies' list in the pom.xml file.
'import okhttp3...' is the right thing to to in your Java file.
pom.xml:
...
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.5.0</version>
</dependency>
</dependencies>
Java file:
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
I'm trying to compile a project (webapp) with Maven and that project "uses" .jar's that are in the Wildfly installation directory (.../Wildfly.../modules/...).
Is there an easy way to import all of these modules through the POM?
I've tried using:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-client-all</artifactId>
<version>10.1.0.Final</version>
</dependency>
And it didn't work.
After that I tried using:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
</dependency>
To no effect either, giving me the following error:
Could not resolve dependencies for project
someproject:someproject:war:0.0.1-SNAPSHOT: The following artifacts
could not be resolved: org.apache.activemq:artemis-
commons:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-core-
client:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-hqclient-
protocol:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-jms-
client:jar:1.1.0.wildfly-017, org.slf4j:jcl-over-slf4j:jar:1.7.7.jbossorg-1:
Could not find artifact org.apache.activemq:artemis-
commons:jar:1.1.0.wildfly-017 in central
(https://repo.maven.apache.org/maven2)
Any tips would be appreciated.
The wildlfy feature pack [1][2], contains pretty much everything that Wildlfy uses for distribution. However, this has way much more dependencies that you actually need, in most cases. So, just be aware of it.
You can also check out Wildlfy BOMs [3][4], which might be useful for you, as well.
Happy Coding!
[1] https://mvnrepository.com/artifact/org.wildfly/wildfly-feature-pack/11.0.0.Final
[2] https://github.com/wildfly/wildfly/tree/master/feature-pack/src/main/resources/modules/system/layers/base
[3] https://mvnrepository.com/artifact/org.wildfly.bom/wildfly-javaee7
[4] https://github.com/wildfly/boms
I have spring project setup on Intellij Idea 2016.2 using Maven. For some reason I cannot import or use any class present in ch.qos.logback.classic package. I tried to invalidate cache, re-import maven dependencies.
For example with
import ch.qos.logback.classic.Level;
the IDE says 'cannot resolve symbol Level'. When compiling from command line it says 'package ch.qos.logback.classic does not exist'. Any suggestion what might be wrong?
Update - found the issue. I had set dependency scope to compile. Updating this fixed the issue.
Have you added the ch.qos.logback:logback-classic Maven artifact in your dependencies?
You should have something like that in your pom :
<dependencies>
...
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
...
<dependencies>
I am trying this tutorial http://www.openimaj.org/tutorial/classification101.html and this code is failing for me:
GroupedDataset<String, VFSListDataset<Record<FImage>>, Record<FImage>> allData =
Caltech101.getData(ImageUtilities.FIMAGE_READER);
The reason is that Record and Caltech101 are not recognized and can't import them. All the other classes work fine.
Here is my maven dependency:
<dependencies>
<dependency>
<artifactId>image-processing</artifactId>
<groupId>org.openimaj</groupId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
I also tried adding all the other dependencies from their website, http://www.openimaj.org/index.html but with no luck.
If anybody that had expirience with OpenImaj, if they could help that would be great.
You need to add the image-annotation Maven dependency.
<dependency>
<groupId>org.openimaj</groupId>
<artifactId>image-annotation</artifactId>
<version>1.3.1</version>
</dependency>
Note that compile scope is the default scope so you can't omit it.