IntellijIDEA not recognizing classes specified in

2019-01-31 11:20发布

I have a project in IntellijIDEA which was created with Maven. I then specified a set of dependencies and external repositories in the Pom.xml file.

The project builds fine on command line if I do "mvn install". When I open any of the code files in the IDE though it says all the classes handled by Maven dependencies aren't recognized - as it would for a normal project if I never added the required JARs to the build path.

I know in my Eclipse Maven projects (rather than IntelliJ) it usually shows an extra directory on the left which says "Maven Dependencies" and lists the JARs pulled in via maven. I don't see that here. What am I doing wrong?


Here's what my screen looks like:

IDE Image

14条回答
Anthone
2楼-- · 2019-01-31 12:01

After installing IntelliJ IDEA on a new computer I found myself with the same issue.

I had to update the remote maven repository. (Settings > Maven > Repositories)

enter image description here

Both local and remote repos needed to be updated. The remote one wasn't updated ever before this. After a restart everything worked fine. You might have to reimport your project.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-31 12:03

For me, what did the trick was to add the dependencies in File > Project Settings > Modules > Dependencies.

查看更多
登录 后发表回答