Editor can't recognize maven dependencies

I've just started to use IDEA (9.0.3) and I faced a problem with maven dependencies. I can build the project using maven task and everything is ok but IDEA editor can't see any of maven dependencies. For example I've line of code:

org.apache.log4j.Logger

but it's marked in red with error 'Cannot resolve symbol ...'. Maven downloaded log4j lib correctly, I can see it in IDEA in project view, as one of external libraries, I can find the class using ctrl+shift+n but editor can't recognize it.

Any hints?

2 comments
Comment actions Permalink

The editor should see it. I would assume that in Maven the dependency is set as standard compile scope.

You can try the following two things

1) Do a force reimport on the maven project. In the Maven Tool window, click on the left most icon, the two arrows. This will force IDEA to re-import the maven project, or, in better terms, to re-sync IDEA's settings with those in your POM(s). Given that you are compiling OK and you are seeing the dependency in the project view, I suspect this will not solve your problem. But it's worth a quick try.

2) Invalidate your caches and restart IDEA. Go to File > Invalidate Caches. After doing such, restart IDEA. It will then recreate the indexes it uses for finding classes. You may have to reimport your Maven project after restart. I suspect this will solve your problem. It's likely that the caches got corrupt. It happens sometimes.

Let us know if that works for you. If not, we can look at some other steps.

0
Comment actions Permalink

I suppose my project wasn't strictly maven project (I created it checkouting sources from svn), i used your hint about reimported maven project. I created new project from  existing pom file and sources and now it works. Thanks a lot!

0

Please sign in to leave a comment.