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条回答
放我归山
2楼-- · 2019-01-31 11:49

For me the problem seems to be a conflict with the maven helper plugin (https://plugins.jetbrains.com/plugin/7179?pr=idea).

I disable it, and it works again :)

查看更多
Root(大扎)
3楼-- · 2019-01-31 11:51

Go to File > Settings > Build, Execution, Deployment > Build Tools > Maven and check the Maven home directory. This should be the same maven installation used for command line

查看更多
你好瞎i
4楼-- · 2019-01-31 11:52

Might be useful to others that were still stuck like me. None of the suggested fix worked. Actually, not before I fixed my main problem which was the installation location of maven.

In my case, I did not use the standard location. Changing that location in the maven settings (Settings/Maven/Maven home repository) did the trick.

My 2 cents.

查看更多
Emotional °昔
5楼-- · 2019-01-31 11:55

For me File>>Invalidate Cache/Restart>>Invalidate and Restart worked in IntelliJ

查看更多
虎瘦雄心在
6楼-- · 2019-01-31 11:56

You could go to:

File > Settings > Build, Execution, Deployment > Build Tools > Maven

and check if your pom.xml is not in the "Ignored Files" list.

查看更多
▲ chillily
7楼-- · 2019-01-31 12:01

For some reason re-import did not do the trick. After looking at this:

http://www.jetbrains.com/idea/webhelp/maven-importing.html

I set auto-import and then the problem went away though; hopefully it helps someone else. Thanks for the ideas everyone :).

查看更多
登录 后发表回答